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.
Summary
[Expand]
Inherited Constants |
From class
java.util.TimeZone
int |
LONG |
A style specifier for getDisplayName() indicating
a long name, such as "Pacific Standard Time." |
int |
SHORT |
A style specifier for getDisplayName() indicating
a short name, such as "PST." |
|
Public Methods |
Object
|
clone()
Returns a copy of this ZoneInfo .
|
boolean
|
equals(Object obj)
Compares the equity of two ZoneInfo objects.
|
synchronized
static
Map<String, String>
|
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
Object
|
clone()
Creates a copy of this TimeZone .
|
synchronized
static
String[]
|
getAvailableIDs()
Gets all the available IDs supported.
|
synchronized
static
String[]
|
getAvailableIDs(int rawOffset)
Gets the available IDs according to the given time zone offset in milliseconds.
|
int
|
getDSTSavings()
Returns the amount of time to be added to local standard time
to get local wall clock time.
|
static
TimeZone
|
getDefault()
Gets the default TimeZone for this host.
|
final
String
|
getDisplayName(Locale locale)
Returns a name of this time zone suitable for presentation to the user
in the specified locale.
|
String
|
getDisplayName(boolean daylight, int style, Locale locale)
Returns a name of this time zone suitable for presentation to the user
in the specified locale.
|
final
String
|
getDisplayName()
Returns a name of this time zone suitable for presentation to the user
in the default locale.
|
final
String
|
getDisplayName(boolean daylight, int style)
Returns a name of this time zone suitable for presentation to the user
in the default locale.
|
String
|
getID()
Gets the ID of this time zone.
|
abstract
int
|
getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds)
Gets the time zone offset, for current date, modified in case of
daylight savings.
|
int
|
getOffset(long date)
Returns the offset of this time zone from UTC at the specified
date.
|
abstract
int
|
getRawOffset()
Returns the amount of time in milliseconds to add to UTC to get
standard time in this time zone.
|
synchronized
static
TimeZone
|
getTimeZone(String ID)
Gets the TimeZone for the given ID.
|
boolean
|
hasSameRules(TimeZone other)
Returns true if this zone has the same rule and offset as another zone.
|
abstract
boolean
|
inDaylightTime(Date date)
Queries if the given date is in daylight savings time in
this time zone.
|
static
void
|
setDefault(TimeZone zone)
Sets the TimeZone that is
returned by the getDefault method.
|
void
|
setID(String ID)
Sets the time zone ID.
|
abstract
void
|
setRawOffset(int offsetMillis)
Sets the base time zone offset to GMT.
|
abstract
boolean
|
useDaylightTime()
Queries if this time zone uses daylight savings time.
|
|
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this object.
|
boolean
|
equals(Object obj)
Indicates whether some other object is "equal to" this one.
|
void
|
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
final
Class<?>
|
getClass()
Returns the runtime class of this Object .
|
int
|
hashCode()
Returns a hash code value for the object.
|
final
void
|
notify()
Wakes up a single thread that is waiting on this object's
monitor.
|
final
void
|
notifyAll()
Wakes up all threads that are waiting on this object's monitor.
|
String
|
toString()
Returns a string representation of the object.
|
final
void
|
wait()
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object.
|
final
void
|
wait(long timeout, int nanos)
Causes the current thread to wait until another thread invokes the
notify() method or the
notifyAll() method for this object, or
some other thread interrupts the current thread, or a certain
amount of real time has elapsed.
|
final
void
|
wait(long timeout)
Causes the current thread to wait until either another thread invokes the
notify() method or the
notifyAll() method for this object, or a
specified amount of time has elapsed.
|
|
Public Constructors
public
ZoneInfo
(String ID, int rawOffset)
A Constructor for CustomID.
Public Methods
public
Object
clone
()
Returns a copy of this ZoneInfo
.
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<String, String>
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.
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. |
public
String
toString
()
Returns a string representation of this time zone.
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.