Java Reference
In-Depth Information
System.out.println("Original Zone Time is less than
new zone time? " +
diffStr );
ZoneId checkOutZoneId = beginTrip.getZone();
ZoneOffset checkOutOffset = beginTrip.getOffset();
ZoneId checkInZoneId = endTrip.getZone();
ZoneOffset checkInOffset = endTrip.getOffset();
System.out.println("Check out zone and offset: "
+ checkOutZoneId + checkOutOffset);
System.out.println("Check in zone and offset: "
+ checkInZoneId + checkInOffset);
}
Here is the result:
Trip Begins: 2014-12-13T13:00-05:00[US/Eastern]
Four Days Later: 2014-12-17T13:00-05:00[US/Eastern]
End trip date/time in original zone:
2014-12-18T10:00-05:00[US/Eastern]
End trip date/time in check-in zone:
2014-12-18T10:00-07:00[US/Mountain]
Original Zone Time is less than new zone time? YES
Check out zone and offset: US/Eastern-05:00
Check in zone and offset: US/Mountain-07:00
How It Works
Time zones add yet another challenge for developers, and the Java Date-Time API
provides an easy facet for working with them. The Date-Time API includes a
java.time.zone package, which contains a number of classes that can assist in
working with time zone data. These classes provide support for time zone rules, data,
and resulting gaps and overlaps in the local timeline that are typically the result of day-
light savings conversions. The classes that make up the zone package are outlined in
Table 4-7 .
Table 4-7 . Time Zone Classes
 
 
Search WWH ::




Custom Search