public class

ZoneInfo

extends TimeZone
java.lang.Object
   ↳ java.util.TimeZone
     ↳ sun.util.calendar.ZoneInfo

Class Overview

ZoneInfo is an implementation subclass of TimeZone that represents GMT offsets and daylight saving time transitions of a time zone.

The daylight saving time transitions are described in the #transitions transitions table consisting of a chronological sequence of transitions of GMT offset and/or daylight saving time changes. Since all transitions are represented in UTC, in theory, ZoneInfo can be used with any calendar systems except for the getOffset method that takes Gregorian calendar date fields.

This table covers transitions from 1900 until 2037 (as of version 1.4), Before 1900, it assumes that there was no daylight saving time and the getOffset methods always return the getRawOffset() value. No Local Mean Time is supported. If a specified date is beyond the transition table and this time zone is supposed to observe daylight saving time in 2037, it delegates operations to a SimpleTimeZone object created using the daylight saving time schedule as of 2037.

The date items, transitions, GMT offset(s), etc. are read from a database file. See ZoneInfoFile for details.

See Also

Summary

[Expand]
Inherited Constants
From class java.util.TimeZone
Public Constructors
ZoneInfo()
A constructor.
ZoneInfo(String ID, int rawOffset)
A Constructor for CustomID.
Public Methods
Object clone()
Returns a copy of this ZoneInfo.
boolean equals(Object obj)
Compares the equity of two ZoneInfo objects.
synchronized static Map<StringString> getAliasTable()
Returns a Map from alias time zone IDs to their standard time zone IDs.
static String[] getAvailableIDs()
Gets all available IDs supported in the Java run-time.
static String[] getAvailableIDs(int rawOffset)
Gets all available IDs that have the same value as the specified raw GMT offset.
int getDSTSavings()
Returns the amount of time in milliseconds that the clock is advanced during daylight saving time is in effect in its last daylight saving time rule.
SimpleTimeZone getLastRuleInstance()
Returns a SimpleTimeZone object that represents the last known daylight saving time rules.
int getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds)
Returns the difference in milliseconds between local time and UTC, taking into account both the raw offset and the effect of daylight savings, for the specified date and time.
int getOffset(long date)
Returns the difference in milliseconds between local time and UTC of given time, taking into account both the raw offset and the effect of daylight savings.
int getOffsets(long utc, int[] offsets)
int getOffsetsByStandard(long standard, int[] offsets)
int getOffsetsByWall(long wall, int[] offsets)
int getRawOffset()
Returns the GMT offset of the current date.
static TimeZone getTimeZone(String ID)
Gets the ZoneInfo for the given ID.
boolean hasSameRules(TimeZone other)
Returns true if this zone has the same raw GMT offset value and transition table as another zone info.
int hashCode()
Returns a hash code value calculated from the GMT offset and transitions.
boolean inDaylightTime(Date date)
Queries if the specified date is in Daylight Saving Time.
boolean isDirty()
synchronized void setRawOffset(int offsetMillis)
Sets the base time zone offset from GMT.
String toString()
Returns a string representation of this time zone.
boolean useDaylightTime()
Queries if this time zone uses Daylight Saving Time in the last known rule.
[Expand]
Inherited Methods
From class java.util.TimeZone
From class java.lang.Object

Public Constructors

public ZoneInfo ()

A constructor.

public ZoneInfo (String ID, int rawOffset)

A Constructor for CustomID.

Public Methods

public Object clone ()

Returns a copy of this ZoneInfo.

Returns
  • a clone of this TimeZone

public boolean equals (Object obj)

Compares the equity of two ZoneInfo objects.

Parameters
obj the object to be compared with
Returns
  • true if given object is same as this ZoneInfo object, false otherwise.

public static synchronized Map<StringString> getAliasTable ()

Returns a Map from alias time zone IDs to their standard time zone IDs.

Returns
  • the Map that holds the mappings from alias time zone IDs to their standard time zone IDs, or null if ZoneInfoMappings file is not available.

public static String[] getAvailableIDs ()

Gets all available IDs supported in the Java run-time.

Returns
  • an array of time zone IDs.

public static String[] getAvailableIDs (int rawOffset)

Gets all available IDs that have the same value as the specified raw GMT offset.

Parameters
rawOffset the GMT offset in milliseconds. This value should not include any daylight saving time.
Returns
  • an array of time zone IDs.

public int getDSTSavings ()

Returns the amount of time in milliseconds that the clock is advanced during daylight saving time is in effect in its last daylight saving time rule.

Returns
  • the number of milliseconds the time is advanced with respect to standard time when daylight saving time is in effect.

public SimpleTimeZone getLastRuleInstance ()

Returns a SimpleTimeZone object that represents the last known daylight saving time rules.

Returns
  • a SimpleTimeZone object or null if this time zone doesn't observe DST.

public int getOffset (int era, int year, int month, int day, int dayOfWeek, int milliseconds)

Returns the difference in milliseconds between local time and UTC, taking into account both the raw offset and the effect of daylight savings, for the specified date and time. This method assumes that the start and end month are distinct. This method assumes a Gregorian calendar for calculations.

Note: In general, clients should use Calendar#ZONE_OFFSET Calendar.get(ZONE_OFFSET) + Calendar#DST_OFFSET Calendar.get(DST_OFFSET) instead of calling this method.

Parameters
era The era of the given date. The value must be either GregorianCalendar.AD or GregorianCalendar.BC.
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 milliseconds in day in standard local time.
Returns
  • The milliseconds to add to UTC to get local time.

public int getOffset (long date)

Returns the difference in milliseconds between local time and UTC of given time, taking into account both the raw offset and the effect of daylight savings.

Parameters
date the milliseconds in UTC
Returns
  • the milliseconds to add to UTC to get local wall time

public int getOffsets (long utc, int[] offsets)

public int getOffsetsByStandard (long standard, int[] offsets)

public int getOffsetsByWall (long wall, int[] offsets)

public int getRawOffset ()

Returns the GMT offset of the current date. This GMT offset value is not modified during Daylight Saving Time.

Returns
  • the GMT offset value in milliseconds to add to UTC time to get local standard time

public static TimeZone getTimeZone (String ID)

Gets the ZoneInfo for the given ID.

Parameters
ID the ID for a ZoneInfo. See TimeZone for detail.
Returns
  • the specified ZoneInfo object, or null if there is no time zone of the ID.

public boolean hasSameRules (TimeZone other)

Returns true if this zone has the same raw GMT offset value and transition table as another zone info. If the specified TimeZone object is not a ZoneInfo instance, this method returns true if the specified TimeZone object has the same raw GMT offset value with no daylight saving time.

Parameters
other the ZoneInfo object to be compared with
Returns
  • true if the given TimeZone has the same GMT offset and transition information; false, otherwise.

public int hashCode ()

Returns a hash code value calculated from the GMT offset and transitions.

Returns
  • a hash code of this time zone

public boolean inDaylightTime (Date date)

Queries if the specified date is in Daylight Saving Time.

Parameters
date the given Date.
Returns
  • true if the given date is in daylight savings time, false, otherwise.

public boolean isDirty ()

public synchronized void setRawOffset (int offsetMillis)

Sets the base time zone offset from GMT. This operation modifies all the transitions of this ZoneInfo object, including historical ones, if applicable.

Parameters
offsetMillis the base time zone offset to GMT.
See Also
  • getRawOffset

public String toString ()

Returns a string representation of this time zone.

Returns
  • the string

public boolean useDaylightTime ()

Queries if this time zone uses Daylight Saving Time in the last known rule.

Returns
  • true if this time zone uses daylight savings time, false, otherwise.