ZoneOffsetTransition

A transition between two offsets caused by a discontinuity _in the local time-line. !(p) A transition between two offsets is normally the result of a daylight savings cutover. The discontinuity is normally a gap _in spring and an overlap _in autumn. {@code ZoneOffsetTransition} models the transition between the two offsets. !(p) Gaps occur where there are local date-times that simply do not exist. An example would be when the offset changes from {@code +03:00} to {@code +04:00}. This might be described as 'the clocks will move forward one hour tonight at 1am'. !(p) Overlaps occur where there are local date-times that exist twice. An example would be when the offset changes from {@code +04:00} to {@code +03:00}. This might be described as 'the clocks will move back one hour tonight at 2am'.

@implSpec This class is immutable and thread-safe.

@since 1.8

Constructors

this
this(LocalDateTime transition, ZoneOffset offsetBefore, ZoneOffset offsetAfter)

Creates an instance defining a transition between two offsets.

this
this(long epochSecond, ZoneOffset offsetBefore, ZoneOffset offsetAfter)

Creates an instance from epoch-second and offsets.

Members

Functions

compareTo
int compareTo(ZoneOffsetTransition transition)

Compares this transition to another based on the transition instant. !(p) This compares the instants of each transition. The offsets are ignored, making this order inconsistent with equals.

getDateTimeAfter
LocalDateTime getDateTimeAfter()

Gets the local transition date-time, as would be expressed with the 'after' offset. !(p) This is the first date-time after the discontinuity, when the new offset applies. !(p) The combination of the 'before' date-time and offset represents the same instant as the 'after' date-time and offset.

getDateTimeBefore
LocalDateTime getDateTimeBefore()

Gets the local transition date-time, as would be expressed with the 'before' offset. !(p) This is the date-time where the discontinuity begins expressed with the 'before' offset. At this instant, the 'after' offset is actually used, therefore the combination of this date-time and the 'before' offset will never occur. !(p) The combination of the 'before' date-time and offset represents the same instant as the 'after' date-time and offset.

getDuration
Duration getDuration()

Gets the duration of the transition. !(p) In most cases, the transition duration is one hour, however this is not always the case. The duration will be positive for a gap and negative for an overlap. Time-zones are second-based, so the nanosecond part of the duration will be zero.

getInstant
Instant getInstant()

Gets the transition instant. !(p) This is the instant of the discontinuity, which is defined as the first instant that the 'after' offset applies. !(p) The methods {@link #getInstant()}, {@link #getDateTimeBefore()} and {@link #getDateTimeAfter()} all represent the same instant.

getOffsetAfter
ZoneOffset getOffsetAfter()

Gets the offset after the transition. !(p) This is the offset _in use on and after the instant of the transition.

getOffsetBefore
ZoneOffset getOffsetBefore()

Gets the offset before the transition. !(p) This is the offset _in use before the instant of the transition.

getValidOffsets
List!(ZoneOffset) getValidOffsets()

Gets the valid offsets during this transition. !(p) A gap will return an empty list, while an overlap will return both offsets.

isGap
bool isGap()

Does this transition represent a gap _in the local time-line. !(p) Gaps occur where there are local date-times that simply do not exist. An example would be when the offset changes from {@code +01:00} to {@code +02:00}. This might be described as 'the clocks will move forward one hour tonight at 1am'.

isOverlap
bool isOverlap()

Does this transition represent an overlap _in the local time-line. !(p) Overlaps occur where there are local date-times that exist twice. An example would be when the offset changes from {@code +02:00} to {@code +01:00}. This might be described as 'the clocks will move back one hour tonight at 2am'.

isValidOffset
bool isValidOffset(ZoneOffset offset)

Checks if the specified offset is valid during this transition. !(p) This checks to see if the given offset will be valid at some point _in the transition. A gap will always return false. An overlap will return true if the offset is either the before or after offset.

opCmp
int opCmp(ZoneOffsetTransition transition)
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Object other)

Checks if this object equals another. !(p) The entire state of the object is compared.

toEpochSecond
long toEpochSecond()

Gets the transition instant as an epoch second.

toHash
size_t toHash()

Returns a suitable hash code.

toString
string toString()

Returns a string describing this object.

writeExternal
void writeExternal(DataOutput _out)

Writes the state to the stream.

Static functions

of
ZoneOffsetTransition of(LocalDateTime transition, ZoneOffset offsetBefore, ZoneOffset offsetAfter)

Obtains an instance defining a transition between two offsets. !(p) Applications should normally obtain an instance from {@link ZoneRules}. This factory is only intended for use when creating {@link ZoneRules}.

readExternal
ZoneOffsetTransition readExternal(DataInput _in)

Reads the state from the stream.

Meta