Returns a copy of this ZonedDateTime, changing the zone offset to the later of the two valid offsets at a local time-line overlap (daylight savings switch). Calling this method will return a zoned date-time with the later of the two valid zones.
package com.logicbig.example.zoneddatetime;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
public class WithLaterOffsetAtOverlapExample {
public static void main(String... args) {
//one hour overlap between 1am to 2am on Nov 5, 2017.
ZonedDateTime d = ZonedDateTime.of(LocalDateTime.of(2017, 11, 5, 1, 15),
ZoneId.of("US/Central"));
System.out.println(d);
ZonedDateTime d3 = d.withLaterOffsetAtOverlap();
System.out.println(d3);
//now d3 will return the earlier time
ZonedDateTime d4 = d3.withEarlierOffsetAtOverlap();
System.out.println(d4);
}
}
Output
2017-11-05T01:15-05:00[US/Central]
2017-11-05T01:15-06:00[US/Central]
2017-11-05T01:15-05:00[US/Central]