In the Java 8-time API, you can create a LocalDateTime that falls on time overlap during DST time changes in the fall (Central European Time).
You can convert this to ZonedDateTime, which is an exact point in time using ZoneId.
Doing this does not actually resolve the ambiguity - there can still be two points in time that correspond to this LocalDateTime and this zone (but at different offsets).
How and why (reference greeting) does the Time API select a summer offset?
@Test
public void TimeSetOnDST() throws Exception {
LocalDateTime time = LocalDateTime.of(2016, 10, 30, 2, 30);
ZonedDateTime of = ZonedDateTime.of(time, ZoneId.of("Europe/Zurich"));
System.out.println(of);
}
source
share