public class ZoneInfo
extends java.util.TimeZone
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 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.
SimpleTimeZone,
Serialized Form| Constructor and Description |
|---|
ZoneInfo()
A constructor.
|
ZoneInfo(java.lang.String ID,
int rawOffset)
A Constructor for CustomID.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Returns a copy of this
ZoneInfo. |
boolean |
equals(java.lang.Object obj)
Compares the equity of two ZoneInfo objects.
|
static java.util.Map<java.lang.String,java.lang.String> |
getAliasTable()
Returns a Map from alias time zone IDs to their standard
time zone IDs.
|
static java.lang.String[] |
getAvailableIDs()
Gets all available IDs supported in the Java run-time.
|
static java.lang.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.
|
java.util.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 java.util.TimeZone |
getTimeZone(java.lang.String ID)
Gets the ZoneInfo for the given ID.
|
int |
hashCode()
Returns a hash code value calculated from the GMT offset and
transitions.
|
boolean |
hasSameRules(java.util.TimeZone other)
Returns true if this zone has the same raw GMT offset value and
transition table as another zone info.
|
boolean |
inDaylightTime(java.util.Date date)
Queries if the specified date is in Daylight Saving Time.
|
boolean |
isDirty() |
boolean |
observesDaylightTime() |
void |
setRawOffset(int offsetMillis)
Sets the base time zone offset from GMT.
|
java.lang.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.
|
public ZoneInfo()
public ZoneInfo(java.lang.String ID,
int rawOffset)
public int getOffset(long date)
getOffset in class java.util.TimeZonedate - the milliseconds in UTCpublic int getOffsets(long utc,
int[] offsets)
public int getOffsetsByStandard(long standard,
int[] offsets)
public int getOffsetsByWall(long wall,
int[] offsets)
public int getOffset(int era,
int year,
int month,
int day,
int dayOfWeek,
int milliseconds)
Note: In general, clients should use
Calendar.get(ZONE_OFFSET) +
Calendar.get(DST_OFFSET)
instead of calling this method.
getOffset in class java.util.TimeZoneera - 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.public void setRawOffset(int offsetMillis)
setRawOffset in class java.util.TimeZoneoffsetMillis - the base time zone offset to GMT.getRawOffsetpublic int getRawOffset()
getRawOffset in class java.util.TimeZonepublic boolean isDirty()
public boolean useDaylightTime()
useDaylightTime in class java.util.TimeZonepublic boolean observesDaylightTime()
observesDaylightTime in class java.util.TimeZonepublic boolean inDaylightTime(java.util.Date date)
inDaylightTime in class java.util.TimeZonepublic int getDSTSavings()
getDSTSavings in class java.util.TimeZonepublic java.lang.String toString()
toString in class java.lang.Objectpublic static java.lang.String[] getAvailableIDs()
public static java.lang.String[] getAvailableIDs(int rawOffset)
rawOffset - the GMT offset in milliseconds. This
value should not include any daylight saving time.public static java.util.TimeZone getTimeZone(java.lang.String ID)
ID - the ID for a ZoneInfo. See TimeZone for detail.public java.util.SimpleTimeZone getLastRuleInstance()
public java.lang.Object clone()
ZoneInfo.clone in class java.util.TimeZonepublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object to be compared withpublic boolean hasSameRules(java.util.TimeZone other)
hasSameRules in class java.util.TimeZoneother - the ZoneInfo object to be compared withTimeZone has the same
GMT offset and transition information; false, otherwise.public static java.util.Map<java.lang.String,java.lang.String> getAliasTable()
ZoneInfoMappings file is not available.