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 Summary
ConstructorsConstructorDescriptionLocalDateTimeRange(LocalDateTime begin, LocalDateTime end) Constructs a new range. -
Method Summary
Modifier and TypeMethodDescriptionintbooleancontains(LocalDateTime value) Inclusive containment test, null-safe.booleangetBegin()getEnd()inthashCode()booleanisClosed()booleanisEmpty()booleanbooleanstatic LocalDateTimeRangeof(LocalDateTime begin, LocalDateTime end) Static factory equivalent toLocalDateTimeRange(LocalDateTime, LocalDateTime).booleanoverlaps(LocalDateTimeRange other) Null-safe overlap test,nullends treated as unbounded.toString()
-
Constructor Details
-
LocalDateTimeRange
Constructs a new range. Either end may benull.- Parameters:
begin- the begin instant (inclusive), ornullend- the end instant (inclusive), ornull
-
-
Method Details
-
of
Static factory equivalent toLocalDateTimeRange(LocalDateTime, LocalDateTime).- Parameters:
begin- the begin instant, ornullend- the end instant, ornull- Returns:
- a new
LocalDateTimeRange
-
getBegin
- Returns:
- the begin instant, or
null
-
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
Inclusive containment test, null-safe.- Parameters:
value- the instant to test- Returns:
trueifvalueis in the range
-
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
Null-safe overlap test,nullends treated as unbounded.- Parameters:
other- the other range- Returns:
trueif the two share at least one instant
-
equals
-
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<LocalDateTimeRange>
-