Package org.zkoss.zul

Class LocalDateRange

java.lang.Object
org.zkoss.zul.LocalDateRange
All Implemented Interfaces:
Serializable, Comparable<LocalDateRange>

public final class LocalDateRange extends Object implements Serializable, Comparable<LocalDateRange>
An immutable LocalDate-based range, the java.time counterpart to DateRange. See DateRange for full semantics — same null handling, same non-swapping policy, same comparison contract.
Since:
11.0.0
Author:
peaker
See Also:
  • Constructor Details

    • LocalDateRange

      public LocalDateRange(LocalDate begin, LocalDate end)
      Constructs a new range. Either end may be null.
      Parameters:
      begin - the begin date (inclusive), or null
      end - the end date (inclusive), or null
  • Method Details

    • of

      public static LocalDateRange of(LocalDate begin, LocalDate end)
      Static factory equivalent to LocalDateRange(LocalDate, LocalDate).
      Parameters:
      begin - the begin date, or null
      end - the end date, or null
      Returns:
      a new LocalDateRange
    • getBegin

      public LocalDate getBegin()
      Returns:
      the begin date, or null
    • getEnd

      public LocalDate getEnd()
      Returns:
      the end date, or null
    • isEmpty

      public boolean isEmpty()
      Returns:
      true if both ends are null.
    • isOpenStart

      public boolean isOpenStart()
      Returns:
      true if only begin is null.
    • isOpenEnd

      public boolean isOpenEnd()
      Returns:
      true if only end is null.
    • isClosed

      public boolean isClosed()
      Returns:
      true if both ends are non-null.
    • contains

      public boolean contains(LocalDate value)
      Inclusive containment test, null-safe. null ends are unbounded.
      Parameters:
      value - the date to test, may be null
      Returns:
      true if value is in the range
    • getDays

      public OptionalLong getDays()
      Returns the inclusive day count wrapped in an OptionalLong. Same-day closed range returns OptionalLong.of(1); inverted closed ranges return a non-positive value (this class does not auto- swap). Returns OptionalLong.empty() for non-closed ranges so callers must explicitly handle the open-ended case (no more sentinel value collisions with legitimate inverted-range counts).
      Returns:
      the inclusive day count for closed ranges, or OptionalLong.empty() when either endpoint is null
    • overlaps

      public boolean overlaps(LocalDateRange other)
      Null-safe overlap test, treating null ends as unbounded.
      Parameters:
      other - the other range
      Returns:
      true if the two share at least one day
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • compareTo

      public int compareTo(LocalDateRange o)
      Specified by:
      compareTo in interface Comparable<LocalDateRange>