OCPtech

Trick Question

What is the output of the following code snippet:

import java.time.*;

public class DaylightSaving {
    public static void main(String[] args) {
        LocalDate date = LocalDate.of(2019, Month.MARCH, 31);
        LocalTime time = LocalTime.of(2,30);
        LocalDateTime dateTime = LocalDateTime.of(date, time);
        ZoneId zone = ZoneId.of("Europe/Paris");
        ZonedDateTime zonedDateTime = ZonedDateTime.of(dateTime, zone);
        System.out.println(zonedDateTime);
    }
}

Scroll down..

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Way down..

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The answer is:

2019-03-31T03:30+02:00[Europe/Paris]

Java knows about daylight saving time!

Leave a Reply

Your email address will not be published.