Package org.zkoss.zul

Class LocalDateRange

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<LocalDateRange>

    public final class LocalDateRange
    extends java.lang.Object
    implements java.io.Serializable, java.lang.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:
    10.4.0
    Author:
    peaker
    See Also:
    Serialized Form
    • Constructor Detail

      • LocalDateRange

        public LocalDateRange​(java.time.LocalDate begin,
                              java.time.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 Detail

      • of

        public static LocalDateRange of​(java.time.LocalDate begin,
                                        java.time.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 java.time.LocalDate getBegin()
        Returns:
        the begin date, or null
      • getEnd

        public java.time.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​(java.time.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 java.util.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​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object