All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.util.TimeZone

java.lang.Object
   |
   +----java.util.TimeZone

public class TimeZone
extends Object
implements Serializable, Cloneable
TimeZone represents a timezone offset, and also figures out daylight savings.

To get a TimeZone, use the TimeZone factory function getTimeZone along with a given timezone ID. For instance, the timezone ID for the Pacific Standard Time zone is "PST".

Clients can use the getAvailableIDs function to iterate through all the available timezone IDs supported. Then clients can choose a supported ID to create a favorite TimeZone.

To get a default TimeZone based on the current timezone where a client lives in, he or she can use the getDefault function. For example, for those who live in Japan, calling getDefault will obtain a TimeZone object based on the Japanese Standard Time.

See Also:
Calendar, GregorianCalendar, SimpleTimeZone

Constructor Index

 o TimeZone()

Method Index

 o clone()
Overrides Cloneable
 o getAvailableIDs()
Gets all the available IDs supported.
 o getAvailableIDs(int)
Gets the available IDs according to the given timezone offset.
 o getDefault()
Gets the default TimeZone for this host.
 o getID()
Gets the ID of this timezone.
 o getOffset(int, int, int, int, int, int)
Gets the timezone offset, for current date, modified in case of daylight savings.
 o getRawOffset()
Gets unmodified offset, NOT modified in case of daylight savings.
 o getTimeZone(String)
Gets the TimeZone for the given ID.
 o inDaylightTime(Date)
Queries if the given date is in Daylight Savings Time in this time zone.
 o setDefault(TimeZone)
Sets timezone to using the given TimeZone.
 o setID(String)
Sets the timezone ID.
 o setRawOffset(int)
Sets the base time zone offset to GMT.
 o useDaylightTime()
Queries if this timezone uses Daylight Savings Time.

Constructors

 o TimeZone
  public TimeZone()

Methods

 o getOffset
  public abstract int getOffset(int era,
                                int year,
                                int month,
                                int day,
                                int dayOfWeek,
                                int milliseconds)
Gets the timezone 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.
Returns:
the offset to add *to* GMT to get local time.
 o setRawOffset
  public abstract void setRawOffset(int offsetMillis)
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.
 o getRawOffset
  public abstract int getRawOffset()
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.
 o getID
  public String getID()
Gets the ID of this timezone.

Returns:
the ID of this timezone.
 o setID
  public void setID(String ID)
Sets the timezone ID. This does not change any other data in the timezone object.

Parameters:
ID - the new timezone ID.
 o useDaylightTime
  public abstract boolean useDaylightTime()
Queries if this timezone uses Daylight Savings Time.

Returns:
true if this timezone uses Daylight Savings Time, false, otherwise.
 o inDaylightTime
  public abstract boolean inDaylightTime(Date date)
Queries if the given date is in Daylight Savings Time in this time zone.

Parameters:
date - the given Date.
Returns:
true if the given date is in Daylight Savings Time, false, otherwise.
 o getTimeZone
  public static synchronized TimeZone getTimeZone(String ID)
Gets the TimeZone for the given ID.

Parameters:
ID - the given ID.
Returns:
a TimeZone.
 o getAvailableIDs
  public static synchronized String[] getAvailableIDs(int rawOffset)
Gets the available IDs according to the given timezone offset.

Parameters:
rawOffset - the given timezone GMT offset.
Returns:
an array of IDs, where the timezone for that ID has the specified GMT offset. For example, {"Phoenix", "Denver"}, since both have GMT-07:00, but differ in daylight savings behavior.
 o getAvailableIDs
  public static synchronized String[] getAvailableIDs()
Gets all the available IDs supported.

Returns:
an array of IDs.
 o getDefault
  public static synchronized TimeZone getDefault()
Gets the default TimeZone for this host.

Returns:
a default TimeZone.
 o setDefault
  public static synchronized void setDefault(TimeZone zone)
Sets timezone to using the given TimeZone.

Parameters:
zone - the given timezone.
 o clone
  public Object clone()
Overrides Cloneable

Overrides:
clone in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index