public final class ZoneOffsetInfo extends Object
The mapping from a local date-time to an offset is not straightforward. There are three cases:
isTransition()
method to handle the gap and overlap. Alternatively use one of the general
methods getEstimatedOffset()
or isValidOffset(ZoneOffset)
.
OffsetInfo is immutable and thread-safe.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object otherInfo)
Checks if this object equals another.
|
ZoneOffset |
getEstimatedOffset()
Gets an estimated offset for the local date-time.
|
LocalDateTime |
getLocalDateTime()
Gets the local date-time that this info is applicable to.
|
ZoneOffset |
getOffset()
Gets the offset applicable at this point on the local time-line.
|
ZoneOffsetTransition |
getTransition()
Gets information about the transition occurring on the local time-line.
|
int |
hashCode()
A suitable hash code for this object.
|
boolean |
isTransition()
Is a transition occurring on the local time-line.
|
boolean |
isValidOffset(ZoneOffset offset)
Checks if the specified offset is valid for this date-time.
|
static ZoneOffsetInfo |
of(LocalDateTime dateTime,
ZoneOffset offset,
ZoneOffsetTransition transition)
Creates an instance representing a simple single offset or a transition.
|
String |
toString()
Returns a string describing this object.
|
public static ZoneOffsetInfo of(LocalDateTime dateTime, ZoneOffset offset, ZoneOffsetTransition transition)
Applications should normally obtain an instance from ZoneRules
.
This constructor is intended for use by implementors of ZoneRules
.
One, and only one, of the offset
or transition
parameters must be specified.
dateTime
- the local date-time that this info applies to, not nulloffset
- the offset applicable at the date-timetransition
- the details of the transition including the offset before and afterpublic LocalDateTime getLocalDateTime()
public boolean isTransition()
A transition may be a gap or overlap and is normally caused by daylight savings cutover.
public ZoneOffset getOffset()
This method is intended for use when isTransition()
returns false
.
public ZoneOffsetTransition getTransition()
This method is intended for use when isTransition()
returns true
public ZoneOffset getEstimatedOffset()
This returns an offset that applies at the local date-time or just after. During a gap the offset after the gap will be returned. During an overlap the offset after the transition will be returned.
public boolean isValidOffset(ZoneOffset offset)
The date-time will typically have a single valid offset.
During a gap, there will be no valid offsets.
During an overlap, there will be two valid offsets.
This method returns true
if the specified offset is one of the
valid offsets.
offset
- the offset to check, null returns falsepublic boolean equals(Object otherInfo)
The entire state of the object is compared.
public int hashCode()
Copyright © 2014. All rights reserved.