public final class ZoneResolvers extends Object
ZoneResolver
.
A ZoneResolver
provides a strategy for handling the gaps and overlaps
on the time-line that occur due to changes in the offset from UTC, usually
caused by daylight saving time.
Modifier and Type | Method and Description |
---|---|
static ZoneResolver |
combination(ZoneResolver gapResolver,
ZoneResolver overlapResolver)
Creates a combined resolver, using two different strategies for gap and overlap.
|
static ZoneResolver |
postGapPreOverlap()
Obtains the post-gap-pre-overlap zone resolver, which returns the instant
after the transition for gaps, and the earlier offset for overlaps.
|
static ZoneResolver |
postTransition()
Obtains the post-transition zone resolver, which returns the instant after the
transition for gaps, and the later offset for overlaps.
|
static ZoneResolver |
preTransition()
Obtains the pre-transition zone resolver, which returns the instant one nanosecond
before the transition for gaps, and the earlier offset for overlaps.
|
static ZoneResolver |
pushForward()
Obtains the push forward resolver, which changes the time of the result
in a gap by adding the length of the gap.
|
static ZoneResolver |
retainOffset()
Obtains the retain offset resolver, which returns the instant after the
transition for gaps, and the same offset for overlaps.
|
static ZoneResolver |
strict()
Obtains the strict zone resolver which rejects all gaps and overlaps
as invalid, resulting in an exception.
|
public static ZoneResolver strict()
Gap - throws an exception.
Overlap - throws an exception.
Other - applies the appropriate offset.
public static ZoneResolver preTransition()
Gap - changes the local date-time to one nanosecond before the transition using the "before" offset.
Overlap - chooses the earlier of the two offsets, which is the "before" offset.
Other - applies the appropriate offset.
public static ZoneResolver postTransition()
Gap - changes the local date-time to the instant of the transition using the "after" offset.
Overlap - chooses the later of the two offsets, which is the "after" offset.
Other - applies the appropriate offset.
public static ZoneResolver postGapPreOverlap()
Gap - changes the local date-time to the instant of the transition using the "after" offset.
Overlap - chooses the earlier of the two offsets, which is the "before" offset.
Other - applies the appropriate offset.
public static ZoneResolver retainOffset()
This resolver is the same as the postGapPreOverlap()
resolver with
one additional rule. When processing an overlap, this resolver attempts
to use the same offset as the offset specified in the old date-time.
If that offset is invalid then the later offset is chosen.
This resolver is most especially useful when adding or subtracting time
from a ZonedDateTime
.
Gap - changes the local date-time to the instant of the transition using the "after" offset.
Overlap - chooses the same offset as the old date-time specified, unless that is invalid when
it chooses the earlier of the two offsets.
Other - applies the appropriate offset.
public static ZoneResolver pushForward()
If the transition is a gap, then the resolver will add the length of the gap in seconds to the local time. For example, given a gap from 01:00 to 02:00 and a time of 01:20, this will add one hour to result in 02:20.
If the transition is an overlap, then the resolver will choose the later of the two offsets.
Gap - changes the local date-time to be later by the length of the gap, using the "after" offset.
Overlap - chooses the later of the two offsets, which is the "after" offset.
Other - applies the appropriate offset.
public static ZoneResolver combination(ZoneResolver gapResolver, ZoneResolver overlapResolver)
If the local date-time is neither a gap nor an overlap, the appropriate offset is simply added.
gapResolver
- the resolver to use for a gap, not nulloverlapResolver
- the resolver to use for an overlap, not null