Java SE API
ZonedDateTime.withLaterOffsetAtOverlap()
Choose the later offset during an overlap; otherwise unchanged. Java SE API; example uses Java 21-compatible syntax.
Formal Syntax & Structure
java syntaxjava
ZonedDateTime withLaterOffsetAtOverlap()Return Value
ZonedDateTime
Choose the later offset during an overlap; otherwise unchanged.
Working Example
Example Snippetjava
import java.math.*;import java.time.*;import java.time.format.*;import java.time.temporal.*;import java.text.*;import java.util.*;public class Main { public static void main(String[] args) throws Exception { ZoneId zone = ZoneId.of("Europe/Stockholm"); LocalDateTime local = LocalDateTime.parse("2024-10-27T02:30"); var offsets = zone.getRules().getValidOffsets(local); System.out.println(offsets.size()); var earlier = ZonedDateTime.ofStrict(local, offsets.get(0), zone); var later = earlier.withLaterOffsetAtOverlap(); System.out.println(earlier.toInstant()); System.out.println(later.toInstant()); }}