Class ZoneResolvers
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Class implementing combination resolver.private static class
Class implementing postGapPreOverlap resolver.private static class
Class implementing postTransition resolver.private static class
Class implementing preTransition resolver.private static class
Class implementing push forward resolver.private static class
Class implementing retain offset resolver.private static class
Class implementing strict resolver. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ZoneResolver
combination
(ZoneResolver gapResolver, ZoneResolver overlapResolver) Creates a combined resolver, using two different strategies for gap and overlap.static ZoneResolver
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
Returns the post-transition zone resolver, which returns the instant after the transition for gaps, and the later offset for overlaps.static ZoneResolver
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
Returns the push forward resolver, which changes the time of the result in a gap by adding the lenth of the gap.static ZoneResolver
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.
-
Constructor Details
-
ZoneResolvers
private ZoneResolvers()Private constructor.
-
-
Method Details
-
strict
Returns the strict zone resolver which rejects all gaps and overlaps as invalid, resulting in an exception.- Returns:
- the strict resolver, never null
-
preTransition
Returns the pre-transition zone resolver, which returns the instant one nanosecond before the transition for gaps, and the earlier offset for overlaps.- Returns:
- the pre-transition resolver, never null
-
postTransition
Returns the post-transition zone resolver, which returns the instant after the transition for gaps, and the later offset for overlaps.- Returns:
- the post-transition resolver, never null
-
postGapPreOverlap
Returns the post-gap-pre-overlap zone resolver, which returns the instant after the transition for gaps, and the earlier offset for overlaps.- Returns:
- the post-transition resolver, never null
-
retainOffset
Returns the retain offset resolver, which returns the instant after the transition for gaps, and the same offset for overlaps.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 chosenThis resolver is most commonly useful when adding or subtracting time from a
ZonedDateTime
.- Returns:
- the retain offset resolver, never null
-
pushForward
Returns the push forward resolver, which changes the time of the result in a gap by adding the lenth of the gap.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.
- Returns:
- the push forward resolver, never null
-
combination
Creates a combined resolver, using two different strategies for gap and overlap.If either argument is
null
then thestrict()
resolver is used.- Parameters:
gapResolver
- the resolver to use for a gap, null means strictoverlapResolver
- the resolver to use for an overlap, null means strict- Returns:
- the combination resolver, never null
-