TimeZone
represents a time zone offset, and also figures out daylight
savings
TimeZone
for the given ID
TimeZone
represents a time zone offset, and also figures out daylight savings.Typically, you get a
TimeZone
usingcreateDefault
which creates aTimeZone
based on the time zone where the program is running. For example, for a program running in Japan,createDefault
creates aTimeZone
object based on Japanese Standard Time.You can also get a
TimeZone
usingcreateTimeZone
along with a time zone ID. For instance, the time zone ID for the Pacific Standard Time zone is "PST". So, you can get a PSTTimeZone
object with:You can useTimeZone *tz = TimeZone::createTimeZone("PST");getAvailableIDs
method to iterate through all the supported time zone IDs. You can then choose a supported ID to get aTimeZone
. If the time zone you want is not represented by one of the supported IDs, then you can create a custom time zone ID with the following syntax:For example, you might specify GMT+14:00 as a custom time zone ID. TheGMT[+|-]hh[[:]mm]TimeZone
that is returned when you specify a custom time zone ID does not include daylight savings time. TimeZone is an abstract class representing a time zone. A TimeZone is needed for Calendar to produce local time for a particular time zone. A TimeZone comprises three basic pieces of information:(Only the ID is actually implemented in TimeZone; subclasses of TimeZone may handle daylight savings time and GMT offset in different ways. Currently we only have one TimeZone subclass: SimpleTimeZone.)
- A time zone offset; that, is the number of milliseconds to add or subtract from a time expressed in terms of GMT to convert it to the same time in that time zone (without taking daylight savings time into account).
- Logic necessary to take daylight savings time into account if daylight savings time is observed in that time zone (e.g., the days and hours on which daylight savings time begins and ends).
- An ID. This is a text string that uniquely identifies the time zone.
The TimeZone class contains a static list containing a TimeZone object for every combination of GMT offset and daylight-savings time rules currently in use in the world, each with a unique ID. Each ID consists of a region (usually a continent or ocean) and a city in that region, separated by a slash, (for example, Pacific Standard Time is "America/Los_Angeles.") Because older versions of this class used three- or four-letter abbreviations instead, there is also a table that maps the older abbreviations to the newer ones (for example, "PST" maps to "America/LosAngeles"). Anywhere the API requires an ID, you can use either form.
To create a new TimeZone, you call the factory function TimeZone::createTimeZone() and pass it a time zone ID. You can use the createAvailableIDs() function to obtain a list of all the time zone IDs recognized by createTimeZone().
You can also use TimeZone::createDefault() to create a TimeZone. This function uses platform-specific APIs to produce a TimeZone for the time zone corresponding to the client's computer's physical location. For example, if you're in Japan (assuming your machine is set up correctly), TimeZone::createDefault() will return a TimeZone for Japanese Standard Time ("Asia/Tokyo").
TimeZone
for the given ID
TimeZone
, or the GMT zone if the given ID
cannot be understood.
TimeZone
, either an abbreviation such as
"PST", a full name such as "America/Los_Angeles", or a custom ID
such as "GMT-8:00".
The caller owns the list that is returned, but does not own the strings contained in that list. Delete the array, but DON'T delete the elements in the array.
. TimeZone* foo = TimeZone::createTimeZone("America/New_York"); . foo.setID("America/Los_Angeles");the time zone's GMT offset and daylight-savings rules don't change to those for Los Angeles. They're still those for New York. Only the ID has changed.)
GMT[+-]hh:mm
.
GMT[+-]hh:mm
.
GMT[+-]hh:mm
.
LONG
or SHORT
GMT[+-]hh:mm
.
LONG
or SHORT
TimeZone
object to be compared with
. Base* polymorphic_pointer = createPolymorphicObject(); . if (polymorphic_pointer->getDynamicClassID() == . Derived::getStaticClassID()) ...
Concrete subclasses of TimeZone must implement getDynamicClassID() and also a static method and data member:
. static UClassID getStaticClassID() { return (UClassID)&fgClassID; } . static char fgClassID;
alphabetic index hierarchy of classes
this page has been generated automatically by doc++
(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de