java::util::TimeZone Class Reference

Inheritance diagram for java::util::TimeZone:

Inheritance graph
java::util::SimpleTimeZonejava::lang::Object
[legend]
Collaboration diagram for java::util::TimeZone:

Collaboration graph
java::lang::Objectjava::lang::Stringjava::lang::Interfacejava::lang::ObjectRefjava::lang::Comparable
[legend]

List of all members.


Detailed Description

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: <blockquote>

 TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
 
</blockquote> You can use 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 you can create a custom time zone ID with the following syntax:

<blockquote>

 GMT[+|-]hh[[:]mm]
 
</blockquote>

For example, you might specify GMT+14:00 as a custom time zone ID. The TimeZone that is returned when you specify a custom time zone ID does not include daylight savings time.

For compatibility with DK 1.1.x, some other three-letter time zone IDs (such as "PST", "CTT", "AST") are also supported. However, their use is deprecated because the same abbreviation is often used for multiple time zones (for example, "CST" could be U.S. "Central Standard Time" and "China Standard Time"), and the Java platform can then only recognize one of them.

See also:
Calendar

GregorianCalendar

SimpleTimeZone

Version:
1.56 03/18/01
Author:
Mark Davis, David Goldsmith, Chen-Lieh Huang, Alan Liu
Since:
DK1.1

Public Types

enum  FORMAT { SHORT, LONG }
enum  MILLIS { millisPerMinute = 60*1000, millisPerHour = 60*millisPerMinute, millisPerDay = 24*millisPerHour, millisPerWeek = 7*millisPerDay }

Public Member Functions

virtual jint getOffset (jint era, jint year, jint month, jint day, jint dayOfWeek, jint milliseconds, jint monthLength, jint prevMonthLength) const =0
 Gets the time zone offset, for current date, modified in case of daylight savings.
virtual void setRawOffset (jint offsetMillis)=0
 Sets the base time zone offset to GMT.
virtual jint getRawOffset () const =0
 Gets unmodified offset, NOT modified in case of daylight savings.
virtual String getID () const
 Gets the ID of this time zone.
virtual void setID (const String &ID)
 Sets the time zone ID.
virtual jboolean useDaylightTime () const =0
 Queries if this time zone uses Daylight Savings Time.
jboolean hasSameRules (const TimeZone &other) const
 Returns true if this zone has the same rule and offset as another zone.

Static Public Member Functions

static TimeZonegetTimeZone (const String &ID)
 Gets the TimeZone for the given ID.
static Array< StringgetAvailableIDs (jint rawOffset)
 Gets the available IDs according to the given time zone offset.
static Array< StringgetAvailableIDs ()
 Gets all the available IDs supported.
static TimeZonegetDefault ()
 Gets the default TimeZone for this host.
static void setDefault (const Ref< TimeZone > &zone)
 Sets the TimeZone that is returned by the getDefault method.

Protected Member Functions

 TimeZone ()

Member Enumeration Documentation

enum java::util::TimeZone::FORMAT

Enumerator:
SHORT  A style specifier for getDisplayName() indicating a short name, such as "PST".

See also:
LONG
Since:
1.2
LONG  A style specifier for getDisplayName() indicating a long name, such as "Pacific Standard Time".

See also:
SHORT
Since:
1.2

enum java::util::TimeZone::MILLIS

Enumerator:
millisPerMinute 
millisPerHour 
millisPerDay 
millisPerWeek 


Constructor & Destructor Documentation

java::util::TimeZone::TimeZone (  )  [protected]


Member Function Documentation

virtual jint java::util::TimeZone::getOffset ( jint  era,
jint  year,
jint  month,
jint  day,
jint  dayOfWeek,
jint  milliseconds,
jint  monthLength,
jint  prevMonthLength 
) const [pure virtual]

Gets the time zone offset, for current date, modified in case of daylight savings.

This is the offset to add *to* UTC to get local time.

Parameters:
era the era of the given date.
year the year in the given date.
month the month in the given date. Month is 0-based. e.g., 0 for January.
day the day-in-month of the given date.
dayOfWeek the day-of-week of the given date.
milliseconds the millis in day in standard local time.
monthLength the length of the given month in days.
prevMonthLength the length of the previous month in days.
Returns:
the offset to add *to* GMT to get local time.

Implemented in java::util::SimpleTimeZone.

virtual void java::util::TimeZone::setRawOffset ( jint  offsetMillis  )  [pure virtual]

Sets the base time zone offset to GMT.

This is the offset to add *to* UTC to get local time.

Parameters:
offsetMillis the given base time zone offset to GMT.

Implemented in java::util::SimpleTimeZone.

virtual jint java::util::TimeZone::getRawOffset (  )  const [pure virtual]

Gets unmodified offset, NOT modified in case of daylight savings.

This is the offset to add *to* UTC to get local time.

Returns:
the unmodified offset to add *to* UTC to get local time.

Implemented in java::util::SimpleTimeZone.

virtual String java::util::TimeZone::getID (  )  const [virtual]

Gets the ID of this time zone.

Returns:
the ID of this time zone.

virtual void java::util::TimeZone::setID ( const String ID  )  [virtual]

Sets the time zone ID.

This does not change any other data in the time zone object.

Parameters:
ID the new time zone ID.

virtual jboolean java::util::TimeZone::useDaylightTime (  )  const [pure virtual]

Queries if this time zone uses Daylight Savings Time.

Returns:
true if this time zone uses Daylight Savings Time, false, otherwise.

Implemented in java::util::SimpleTimeZone.

static TimeZone& java::util::TimeZone::getTimeZone ( const String ID  )  [static]

Gets the TimeZone for the given ID.

Parameters:
ID the ID for a TimeZone, either an abbreviation such as "PST", a full name such as "America/Los_Angeles", or a custom ID such as "GMT-8:00". Note that the support of abbreviations is for DK 1.1.x compatibility only and full names should be used.
Returns:
the specified TimeZone, or the GMT zone if the given ID cannot be understood.

static Array<String> java::util::TimeZone::getAvailableIDs ( jint  rawOffset  )  [static]

Gets the available IDs according to the given time zone offset.

Parameters:
rawOffset the given time zone GMT offset.
Returns:
an array of IDs, where the time zone for that ID has the specified GMT offset. For example, "America/Phoenix" and "America/Denver" both have GMT-07:00, but differ in daylight savings behavior.

static Array<String> java::util::TimeZone::getAvailableIDs (  )  [static]

Gets all the available IDs supported.

Returns:
an array of IDs.

static TimeZone& java::util::TimeZone::getDefault (  )  [static]

Gets the default TimeZone for this host.

The source of the default TimeZone may vary with implementation.

Returns:
a default TimeZone.

static void java::util::TimeZone::setDefault ( const Ref< TimeZone > &  zone  )  [static]

Sets the TimeZone that is returned by the getDefault method.

If zone is null, reset the default to the value it had originally when the VM first started.

Parameters:
zone the new default time zone

jboolean java::util::TimeZone::hasSameRules ( const TimeZone other  )  const

Returns true if this zone has the same rule and offset as another zone.

That is, if this zone differs only in ID, if at all. Returns false if the other zone is null.

Parameters:
other the TimeZone object to be compared with
Returns:
true if the other zone is not null and is the same as this one, with the possible exception of the ID
Since:
1.2

Reimplemented in java::util::SimpleTimeZone.


The documentation for this class was generated from the following file:
Generated on Fri May 16 11:56:52 2008 for CrossPlatformJavaLikeC++API by  doxygen 1.5.3