Package org.zkoss.zul
Class LocalDateTimeRange
- java.lang.Object
-
- org.zkoss.zul.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 immutableLocalDateTime-based range, thejava.timecounterpart toDateRangefor date-with-time scenarios. SeeDateRangefor general semantics; the only difference here is thatgetDuration()returns aDuration(ornullwhen not closed) instead of a day count.- Since:
- 10.4.0
- Author:
- peaker
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description LocalDateTimeRange(java.time.LocalDateTime begin, java.time.LocalDateTime end)Constructs a new range.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(LocalDateTimeRange o)booleancontains(java.time.LocalDateTime value)Inclusive containment test, null-safe.booleanequals(java.lang.Object o)java.time.LocalDateTimegetBegin()java.time.DurationgetDuration()Returns theDurationbetweenbeginandendfor a closed range, ornullotherwise.java.time.LocalDateTimegetEnd()inthashCode()booleanisClosed()booleanisEmpty()booleanisOpenEnd()booleanisOpenStart()static LocalDateTimeRangeof(java.time.LocalDateTime begin, java.time.LocalDateTime end)Static factory equivalent toLocalDateTimeRange(LocalDateTime, LocalDateTime).booleanoverlaps(LocalDateTimeRange other)Null-safe overlap test,nullends treated as unbounded.java.lang.StringtoString()
-
-
-
Method Detail
-
of
public static LocalDateTimeRange of(java.time.LocalDateTime begin, java.time.LocalDateTime end)
Static factory equivalent toLocalDateTimeRange(LocalDateTime, LocalDateTime).- Parameters:
begin- the begin instant, ornullend- the end instant, ornull- Returns:
- a new
LocalDateTimeRange
-
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:
trueif both ends arenull.
-
isOpenStart
public boolean isOpenStart()
- Returns:
trueif onlybeginisnull.
-
isOpenEnd
public boolean isOpenEnd()
- Returns:
trueif onlyendisnull.
-
isClosed
public boolean isClosed()
- Returns:
trueif 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:
trueifvalueis in the range
-
getDuration
public java.time.Duration getDuration()
Returns theDurationbetweenbeginandendfor a closed range, ornullotherwise. The duration is signed (it can be negative ifendis beforebegin, since the class does not auto-swap).- Returns:
- the duration, or
nullfor non-closed ranges
-
overlaps
public boolean overlaps(LocalDateTimeRange other)
Null-safe overlap test,nullends treated as unbounded.- Parameters:
other- the other range- Returns:
trueif the two share at least one instant
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
compareTo
public int compareTo(LocalDateTimeRange o)
- Specified by:
compareToin interfacejava.lang.Comparable<LocalDateTimeRange>
-
-