I am using the new java.time implementation of Java 8, which is of interest for outputting UTC to CET , the result of a time conversion.
ZonedDateTime utcTime = ZonedDateTime.of(2014, 7, 1, 8, 0, 0, 0, ZoneId.of("UTC")); ZonedDateTime cetTime = ZonedDateTime.ofInstant(utcTime.toInstant(), ZoneId.of("CET")); System.out.println("Summer-UTC-Time: " + utcTime); System.out.println("Summer-CET-Time: " + cetTime); System.out.println(); utcTime = ZonedDateTime.of(2014, 1, 1, 8, 0, 0, 0, ZoneId.of("UTC")); cetTime = ZonedDateTime.ofInstant(utcTime.toInstant(), ZoneId.of("CET")); System.out.println("Winter-UTC-Time: " + utcTime); System.out.println("Winter-CET-Time: " + cetTime);
I expected CET time to always be +1 from UTC, but instead I got:
Summer-UTC-Time: 2014-07-01T08:00Z[UTC] Summer-CET-Time: 2014-07-01T10:00+02:00[CET] -> +2 **Unexpected** Winter-UTC-Time: 2014-01-01T08:00Z[UTC] Winter-CET-Time: 2014-01-01T09:00+01:00[CET] -> +1 Expected
Apparently, I have to deal with daylight saving time, which I did not expect when using CET. Is java.time CET CEST ? And if so, which zone should I use if I need a CET?
source share