public interface ZoneResolver
LocalDateTime
to an OffsetDateTime
using the rules of a time-zone.
A time-zone provides rules for when and by how much the offset changes for a given location. These rules can result in gaps in the local time-line, such as at the spring daylight savings cutover, and overlaps, such as at the autumn cutover.
Implementations of this resolver handles these missing and overlapping cases by either throwing an exception, selecting the appropriate offset or changing the local date-time.
Modifier and Type | Method and Description |
---|---|
OffsetDateTime |
resolve(LocalDateTime desiredLocalDateTime,
ZoneOffsetInfo info,
ZoneRules rules,
ZoneId zone,
OffsetDateTime oldDateTime)
Resolves the new local date-time to an offset date-time using the zone.
|
OffsetDateTime resolve(LocalDateTime desiredLocalDateTime, ZoneOffsetInfo info, ZoneRules rules, ZoneId zone, OffsetDateTime oldDateTime)
This takes the local date-time and applies the rules of the time-zone to create the resultant offset date-time. The result must be a valid date-time for the time-zone.
The resolution may use the optional "old" date-time. For example, this might be used to pick the closest offset.
The method caller supplies the ZoneOffsetInfo
and ZoneRules
to use.
These should be used in preference to methods on the supplied ZoneId
.
Most implementations query the info to determine if the local date-time
is in a gap or overlap, adjusting accordingly.
desiredLocalDateTime
- the desired local date-time, not nullinfo
- the zone-offset info from the rules for the local date-time, not nullrules
- the time-zone rules to use, not nullzone
- the target time-zone, not normally used by implementations, not nulloldDateTime
- the old date-time before any adjustment, may be nullDateTimeException
- if the date-time cannot be resolved