Package org.zkoss.zul

Class LocalDateTimeRange

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

public final class LocalDateTimeRange extends Object implements Serializable, 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:
11.0.0
Author:
peaker
See Also:
  • Constructor Details

    • LocalDateTimeRange

      public LocalDateTimeRange(LocalDateTime begin, 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 Details

    • of

      public static LocalDateTimeRange of(LocalDateTime begin, LocalDateTime end)
      Parameters:
      begin - the begin instant, or null
      end - the end instant, or null
      Returns:
      a new LocalDateTimeRange
    • getBegin

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

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

      public 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(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(LocalDateTimeRange o)
      Specified by:
      compareTo in interface Comparable<LocalDateTimeRange>