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 Savings Time.
ZoneResolvers is a utility class. All resolvers returned are immutable and thread-safe.
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()
Returns 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()
Returns the post-transition zone resolver, which returns the instant
after the transition for gaps, and the later offset for overlaps.
|
static ZoneResolver |
preTransition()
Returns 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()
Returns the push forward resolver, which changes the time of the result
in a gap by adding the lenth of the gap.
|
static ZoneResolver |
retainOffset()
Returns the retain offset resolver, which returns the instant after the
transition for gaps, and the same offset for overlaps.
|
static ZoneResolver |
strict()
Returns the strict zone resolver which rejects all gaps and overlaps
as invalid, resulting in an exception.
|
public static ZoneResolver strict()
public static ZoneResolver preTransition()
public static ZoneResolver postTransition()
public static ZoneResolver postGapPreOverlap()
public static ZoneResolver retainOffset()
This resolver is the same as the {postTransition()
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 commonly useful when adding or subtracting time
from a ZonedDateTime
.
public static ZoneResolver pushForward()
If the discontinuity 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 discontinuity is an overlap, then the resolver will choose the later of the two offsets.
public static ZoneResolver combination(ZoneResolver gapResolver, ZoneResolver overlapResolver)
If either argument is null
then the strict()
resolver is used.
gapResolver
- the resolver to use for a gap, null means strictoverlapResolver
- the resolver to use for an overlap, null means strictCopyright © 2014. All rights reserved.