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));
To achieve answer mark as correct, the line:2015-11-01T02:00-05:00[US/Eastern]
2015-11-01T01:00-04:00[US/Eastern]
-1
Code: Select all
long x = ChronoUnit.HOURS.between(ld1,ld2);
long x = ChronoUnit.HOURS.between(zd1,zd2);