    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

##

TimeZone()

##

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

##

TimeZone

      public TimeZone()

##

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.

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.

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.

getID

      public String getID()

  Gets the ID of this timezone.

  Returns:
    the ID of this timezone.

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.

useDaylightTime

      public abstract boolean useDaylightTime()

  Queries if this timezone uses Daylight Savings Time.

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

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.

getTimeZone

      public static synchronized TimeZone getTimeZone(String ID)

  Gets the TimeZone for the given ID.

  Parameters:
    ID - the given ID.
  Returns:
    a TimeZone.

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.

getAvailableIDs

      public static synchronized String[] getAvailableIDs()

  Gets all the available IDs supported.

  Returns:
    an array of IDs.

getDefault

      public static synchronized TimeZone getDefault()

  Gets the default TimeZone for this host.

  Returns:
    a default TimeZone.

setDefault

      public static synchronized void setDefault(TimeZone zone)

  Sets timezone to using the given TimeZone.

  Parameters:
    zone - the given timezone.

clone

      public Object clone()

  Overrides Cloneable

  Overrides:
    clone in class Object

    All Packages  Class Hierarchy  This Package  Previous  Next  Index