Returns a copy of this ZonedDateTime, changing the zone offset to the earlier of the two valid offsets at a local time-line overlap. The overlap happens when DST period finishes and one hour is returned. In this scenario, there are two valid offsets for the local date-time. Calling this method will return a zoned date-time with the earlier of the two zones.
package com.logicbig.example.zoneddatetime;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
public class WithEarlierOffsetAtOverlapExample {
public static void main(String... args) {
//one hr overlap between 1am to 2m on Nov 5, 2017.
ZonedDateTime d = ZonedDateTime.ofLocal(LocalDateTime.of(2017, 11, 5, 1, 15)
, ZoneId.of("US/Central"), ZoneOffset.ofHours(-6));
System.out.println(d);
ZonedDateTime d2 = d.withEarlierOffsetAtOverlap();
System.out.println(d2);
}
}
Output
2017-11-05T01:15-06:00[US/Central]
2017-11-05T01:15-05:00[US/Central]