Gets the offset applicable at the specified local date-time in these rules.
The mapping from a local date-time to an offset is not straightforward. There are three cases:
There are various ways to handle the conversion from a LocalDateTime.
One technique, using this method, would be:
List<ZoneOffset> validOffsets = rules.getOffset(localDT);
if (validOffsets.size() == 1) {
// Normal case: only one valid offset
zoneOffset = validOffsets.get(0);
} else {
// Gap or Overlap: determine what to do from transition (which will be non-null)
ZoneOffsetTransition trans = rules.getTransition(localDT);
}
In theory, it is possible for there to be more than two valid offsets. This would happen if clocks to be put back more than once in quick succession. This has never happened in the history of time-zones and thus has no special handling. However, if it were to happen, then the list would return more than 2 entries.
localDateTime | the local date-time to query for valid offsets, not null, but null may be ignored if the rules have a single offset for all instants |
Diagram: Zone