Java Reference
In-Depth Information
ZoneOffset offset = rules.getOffset(now);
System.out.println("Zone offset: " + offset);
List<ZoneOffsetTransition> transitions = rules.getTransitions();
System.out.println(transitions);
}
}
Current Date Time: 2014-01-03T16:05:13.035
Zone ID: +06:00
isFixedOffset(): true
Zone offset: +06:00
[]
Zone ID: Asia/Dhaka
isFixedOffset(): false
Zone offset: +06:00
[Transition[Overlap at 1890-01-01T00:00+06:01:40 to +05:53:20], ..., Transition[Gap at
2009-06-19T23:00+06:00 to +07:00], Transition[Overlap at 2009-12-31T23:59+07:00 to +06:00]]
Zone ID: America/Chicago
isFixedOffset(): false
Zone offset: -06:00
[Transition[Overlap at 1883-11-18T12:09:24-05:50:36 to -06:00], ..., Transition[Gap at
2008-03-09T02:00-06:00 to -05:00], Transition[Overlap at 2008-11-02T02:00-05:00 to -06:00]]
Several organizations and groups provide a set of time zone rules as a database that contains the code and data
for all time zones in the world. Each provider is given a unique group ID. One of the standard rules providers is a TZ
database that is identified by TZDB group ID. Please refer to www.twinsun.com/tz/tz-link.htm for more details on
the TZ database.
As the rules for a time zone change over time, a group provides multiple versions of rules data for different
regions. Typically, a region represents a time zone where the time zone rules are the same. Each group has its own
naming scheme for the versions and regions.
TZDB stores region names in a [area]/[city] format. Examples of some regions names are Africa/Tunis,
America/Chicago, Asia/Kolkata, Asia/Tokyo, Europe/Istanbul, Europe/London, and Europe/Moscow.
The Date-Time API uses the TZDB as the default time zone rules provider. If you are using a region-based zone ID
from the TZDB, use the region name as the zone id. The region name should be prefixed with the group ID of the provider
in the form of “group~region” if a group other than TZDB is used for zone rules. For example, if you are using International
Air Transport Association (IATA) provider, use “IATA~CHI” for the Chicago region. Please refer to the ZoneRulesProvider
class in the java.time.zone package for more details on how to register your own zone rules provider.
Useful Datetime-Related Enums
Before I discuss classes that represent different combinations of date and time, it is worth discussing some enums
representing constants for date and time components:
Month
DayOfWeek
ChronoField
ChronoUnit
 
 
Search WWH ::




Custom Search