Exam 1z0-809 All QuestionsBrowse all questions from this exam
Question 189

Given the code fragment:

ZonedDateTime depart = ZonedDateTime.of(2015, 1, 15, 1, 0, 0, 0, ZoneID.of("UTC-7"));

ZonedDateTime arrive = ZonedDateTime.of(2015, 1, 15, 9, 0, 0, 0, ZoneID.of("UTC-5")); long hrs = ChronoUnit.HOURS.between(depart, arrive); //line n1

System.out.println("Travel time is" + hrs + "hours");

What is the result?

    Correct Answer: B

    Given the code fragment, the key point is to correctly calculate the time difference between two ZonedDateTime objects in different time zones. The departure time is set to 1 AM at UTC-7, which corresponds to 8 AM in UTC. The arrival time is set to 9 AM at UTC-5, which corresponds to 2 PM in UTC. The difference between 2 PM UTC and 8 AM UTC is 6 hours. Therefore, the correct result for the travel time is 6 hours.

Discussion
Abdullah_RahahleahOption: B

6 hours is the corrrect answer

steefaandOption: B

B is correct. Setting those times to GMT you have 8 and 14 values for hours.

duydnOption: B

B is correct. pay attention at UCT-7 and UTC-5

WilsonKKerllOption: B

Answer is B