Package org.zkoss.zul

Class LocalDateTimeRange

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

    public final class LocalDateTimeRange
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Comparable<LocalDateTimeRange>
    An immutable LocalDateTime-based range, the java.time counterpart to DateRange for date-with-time scenarios. See DateRange for general semantics; the only difference here is that getDuration() returns a Duration (or null when not closed) instead of a day count.
    Since:
    10.4.0
    Author:
    peaker
    See Also:
    Serialized Form
    • Constructor Detail

      • LocalDateTimeRange

        public LocalDateTimeRange​(java.time.LocalDateTime begin,
                                  java.time.LocalDateTime end)
        Constructs a new range. Either end may be null.
        Parameters:
        begin - the begin instant (inclusive), or null
        end - the end instant (inclusive), or null
    • Method Detail

      • getBegin

        public java.time.LocalDateTime getBegin()
        Returns:
        the begin instant, or null
      • getEnd

        public java.time.LocalDateTime getEnd()
        Returns:
        the end instant, 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.LocalDateTime value)
        Inclusive containment test, null-safe.
        Parameters:
        value - the instant to test
        Returns:
        true if value is in the range
      • getDuration

        public java.time.Duration getDuration()
        Returns the Duration between begin and end for a closed range, or null otherwise. The duration is signed (it can be negative if end is before begin, since the class does not auto-swap).
        Returns:
        the duration, or null for non-closed ranges
      • overlaps

        public boolean overlaps​(LocalDateTimeRange other)
        Null-safe overlap test, null ends treated as unbounded.
        Parameters:
        other - the other range
        Returns:
        true if the two share at least one instant
      • 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