Package org.zkoss.zul
Class ZonedDateTimeRange
java.lang.Object
org.zkoss.zul.ZonedDateTimeRange
- All Implemented Interfaces:
Serializable,Comparable<ZonedDateTimeRange>
public final class ZonedDateTimeRange
extends Object
implements Serializable, Comparable<ZonedDateTimeRange>
An immutable
ZonedDateTime-based range, the java.time
counterpart to DateRange for time-zone-aware scenarios.
Equality and ordering compare ZonedDateTime values directly, which
means two ranges with the same instant but different zones are not
equal. contains(ZonedDateTime) and overlaps(ZonedDateTimeRange)
compare by absolute instant (ChronoZonedDateTime.isBefore(java.time.chrono.ChronoZonedDateTime))
and therefore work correctly across zones.
- Since:
- 11.0.0
- Author:
- peaker
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionZonedDateTimeRange(ZonedDateTime begin, ZonedDateTime end) Constructs a new range. -
Method Summary
Modifier and TypeMethodDescriptionintbooleancontains(ZonedDateTime value) Inclusive, instant-based containment test (null-safe).booleanZone-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.getBegin()getEnd()inthashCode()booleanisClosed()booleanisEmpty()booleanbooleanstatic ZonedDateTimeRangeof(ZonedDateTime begin, ZonedDateTime end) Static factory equivalent toZonedDateTimeRange(ZonedDateTime, ZonedDateTime).booleanoverlaps(ZonedDateTimeRange other) Instant-based, null-safe overlap test.toString()
-
Constructor Details
-
ZonedDateTimeRange
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 toZonedDateTimeRange(ZonedDateTime, ZonedDateTime).- Parameters:
begin- the begin instant, ornullend- the end instant, ornull- Returns:
- a new
ZonedDateTimeRange
-
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, instant-based containment test (null-safe).- Parameters:
value- the instant to test- Returns:
trueifvalueis in the range
-
getDuration
- Returns:
- the duration, or
nullfor non-closed ranges
-
overlaps
Instant-based, null-safe overlap test.- Parameters:
other- the other range- Returns:
trueif the two share at least one instant
-
equals
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. -
hashCode
public int hashCode() -
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<ZonedDateTimeRange>
-