TimeZone represents a time zone offset, and also figures out daylight
savings.
Typically, you get a TimeZone using getDefault
which creates a TimeZone based on the time zone where the program
is running. For example, for a program running in Japan, getDefault
creates a TimeZone object based on Japanese Standard Time.
You can also get a TimeZone using getTimeZone
along with a time zone ID. For instance, the time zone ID for the
U.S. Pacific Time zone is "America/Los_Angeles". So, you can get a
U.S. Pacific Time TimeZone object with:
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
You can use the getAvailableIDs method to iterate through
all the supported time zone IDs. You can then choose a
supported ID to get a TimeZone.
If the time zone you want is not represented by one of the
supported IDs, then a custom time zone ID can be specified to
produce a TimeZone. The syntax of a custom time zone ID is:
Hours must be between 0 to 23 and Minutes must be between 00 to 59. For example, "GMT+10" and "GMT+0010" mean ten hours and ten minutes ahead of GMT, respectively.CustomID:GMTSign Hours:MinutesGMTSign Hours MinutesGMTSign Hours Sign: one of+ -Hours: Digit Digit Digit Minutes: Digit Digit Digit: one of0 1 2 3 4 5 6 7 8 9
The format is locale independent and digits must be taken from the
Basic Latin block of the Unicode standard. No daylight saving time
transition schedule can be specified with a custom time zone ID. If
the specified string doesn't match the syntax, "GMT"
is used.
When creating a TimeZone, the specified custom time
zone ID is normalized in the following syntax:
For example, TimeZone.getTimeZone("GMT-8").getID() returns "GMT-08:00".NormalizedCustomID:GMTSign TwoDigitHours:Minutes Sign: one of+ -TwoDigitHours: Digit Digit Minutes: Digit Digit Digit: one of0 1 2 3 4 5 6 7 8 9
implements
Calendar, GregorianCalendar, SimpleTimeZone