Page 1 of 1

About Question enthuware.ocpjp.v8.2.1749 :

Posted: Tue Sep 22, 2015 1:13 pm
by lveto15
My answer was mark as incorrect, so I have run this example, with some extra loggin:

Code: Select all

LocalDateTime ld1 = LocalDateTime.of(2015,Month.NOVEMBER,1,2,0);
ZonedDateTime z1 = ZonedDateTime.of(ld1, ZoneId.of("US/Eastern"));
System.out.println(z1);

LocalDateTime ld2 = LocalDateTime.of(2015,11,1,1,0);
ZonedDateTime z2 = ZonedDateTime.of(ld2, ZoneId.of("US/Eastern"));
System.out.println(z2);

System.out.println(ChronoUnit.HOURS.between(ld1,ld2));
Result was:
2015-11-01T02:00-05:00[US/Eastern]
2015-11-01T01:00-04:00[US/Eastern]
-1
To achieve answer mark as correct, the line:

Code: Select all

long x = ChronoUnit.HOURS.between(ld1,ld2);
has to be changed to:
long x = ChronoUnit.HOURS.between(zd1,zd2);

Re: About Question enthuware.ocpjp.v8.2.1749 :

Posted: Tue Sep 22, 2015 10:00 pm
by admin
You are right. Fixed.
thank you for your feedback!
Paul.