Package org.zkoss.zul
Class ZonedDateTimeRange
- java.lang.Object
-
- org.zkoss.zul.ZonedDateTimeRange
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<ZonedDateTimeRange>
public final class ZonedDateTimeRange extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<ZonedDateTimeRange>
An immutableZonedDateTime-based range, thejava.timecounterpart toDateRangefor time-zone-aware scenarios.Equality and ordering compare
ZonedDateTimevalues directly, which means two ranges with the same instant but different zones are not equal.contains(ZonedDateTime)andoverlaps(ZonedDateTimeRange)compare by absolute instant (ChronoZonedDateTime.isBefore(java.time.chrono.ChronoZonedDateTime)) and therefore work correctly across zones.- Since:
- 10.4.0
- Author:
- peaker
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ZonedDateTimeRange(java.time.ZonedDateTime begin, java.time.ZonedDateTime end)Constructs a new range.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(ZonedDateTimeRange o)booleancontains(java.time.ZonedDateTime value)Inclusive, instant-based containment test (null-safe).booleanequals(java.lang.Object o)Zone-identity semantics. Equality delegates toZonedDateTime.equals(Object), which compares the local date-time and the zone — two ranges representing the same instants in different zones (e.g.java.time.ZonedDateTimegetBegin()java.time.DurationgetDuration()Returns theDurationbetweenbeginandendfor a closed range, ornullotherwise.java.time.ZonedDateTimegetEnd()inthashCode()booleanisClosed()booleanisEmpty()booleanisOpenEnd()booleanisOpenStart()static ZonedDateTimeRangeof(java.time.ZonedDateTime begin, java.time.ZonedDateTime end)Static factory equivalent toZonedDateTimeRange(ZonedDateTime, ZonedDateTime).booleanoverlaps(ZonedDateTimeRange other)Instant-based, null-safe overlap test.java.lang.StringtoString()
-
-
-
Method Detail
-
of
public static ZonedDateTimeRange of(java.time.ZonedDateTime begin, java.time.ZonedDateTime end)
Static factory equivalent toZonedDateTimeRange(ZonedDateTime, ZonedDateTime).- Parameters:
begin- the begin instant, ornullend- the end instant, ornull- Returns:
- a new
ZonedDateTimeRange
-
getBegin
public java.time.ZonedDateTime getBegin()
- Returns:
- the begin instant, or
null
-
getEnd
public java.time.ZonedDateTime 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.ZonedDateTime value)
Inclusive, instant-based 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.- Returns:
- the duration, or
nullfor non-closed ranges
-
overlaps
public boolean overlaps(ZonedDateTimeRange other)
Instant-based, null-safe overlap test.- Parameters:
other- the other range- Returns:
trueif the two share at least one instant
-
equals
public boolean equals(java.lang.Object o)
Zone-identity semantics. Equality delegates toZonedDateTime.equals(Object), which compares the local date-time and the zone — two ranges representing the same instants in different zones (e.g.2026-01-01T12:00+09:00vs2026-01-01T03:00Z) are not equal here, even thoughcontains(ZonedDateTime)andoverlaps(ZonedDateTimeRange)would treat them as equivalent (those use instant-basedisBefore/isAfter). Bind-driven dirty checks that re-set the value to an instant-equivalent but zone-different range will therefore see the property as changed.- 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(ZonedDateTimeRange o)
- Specified by:
compareToin interfacejava.lang.Comparable<ZonedDateTimeRange>
-
-