| java.lang.Object com.ibm.icu.util.TimeZone
All known Subclasses: com.ibm.icu.impl.JDKTimeZone, com.ibm.icu.impl.OlsonTimeZone,
TimeZone | abstract public class TimeZone implements Serializable,Cloneable(Code) | | TimeZone represents a time zone offset, and also figures out daylight
savings.
Typically, you get a TimeZone using getDefault
which creates a TimeZone based on the time zone where the program
is running. For example, for a program running in Japan, getDefault
creates a TimeZone object based on Japanese Standard Time.
You can also get a TimeZone using getTimeZone
along with a time zone ID. For instance, the time zone ID for the
U.S. Pacific Time zone is "America/Los_Angeles". So, you can get a
U.S. Pacific Time TimeZone object with:
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles");
You can use getAvailableIDs method to iterate through
all the supported time zone IDs. You can then choose a
supported ID to get a TimeZone .
If the time zone you want is not represented by one of the
supported IDs, then you can create a custom time zone ID with
the following syntax:
GMT[+|-]hh[[:]mm]
For example, you might specify GMT+14:00 as a custom
time zone ID. The TimeZone that is returned
when you specify a custom time zone ID does not include
daylight savings time.
For compatibility with JDK 1.1.x, some other three-letter time zone IDs
(such as "PST", "CTT", "AST") are also supported. However, their
use is deprecated because the same abbreviation is often used
for multiple time zones (for example, "CST" could be U.S. "Central Standard
Time" and "China Standard Time"), and the Java platform can then only
recognize one of them.
See Also: Calendar See Also: GregorianCalendar See Also: SimpleTimeZone author: Mark Davis, David Goldsmith, Chen-Lieh Huang, Alan Liu |
Field Summary | |
final static int[][] | GREGORIAN_MONTH_COUNT For each month, the days in a non-leap year before the start
the of month, and the days in a leap year before the start of
the month. | final public static int | LONG | final protected static int | MILLIS_PER_DAY The number of milliseconds in one day. | final protected static int | MILLIS_PER_HOUR The number of milliseconds in an hour. | final public static int | SHORT |
Constructor Summary | |
public | TimeZone() Default constructor. |
Method Summary | |
public Object | clone() | static void | computeGregorianFields(long day, int fields) Compute the Gregorian calendar year, month, and day of month
from the epoch day, and return them in the given array. | public static int | countEquivalentIDs(String id) Returns the number of IDs in the equivalency group that
includes the given ID. | public boolean | equals(Object obj) Return true if obj is a TimeZone with the same class and ID as this. | static long | floorDivide(long numerator, long denominator) Divide two long integers, returning the floor of the quotient. | static int | floorDivide(long numerator, int denominator, int[] remainder) Divide two integers, returning the floor of the quotient, and
the modulus remainder.
Unlike the built-in division, this is mathematically well-behaved.
E.g., -1/4 => 0 and -1%4 => -1,
but floorDivide(-1,4) => -1 with remainder[0] => 3.
TODO: This duplicates a method in Calendar; clean up and
consolidate in ICU 3.0.
Parameters: numerator - the numerator Parameters: denominator - a divisor which must be > 0 Parameters: remainder - an array of at least one element in which the valuenumerator mod denominator is returned. | public static String[] | getAvailableIDs(int rawOffset) Return a new String array containing all system TimeZone IDs
with the given raw offset from GMT. | public static String[] | getAvailableIDs(String country) Return a new String array containing all system TimeZone IDs
associated with the given country. | public static String[] | getAvailableIDs() Return a new String array containing all system TimeZone IDs. | public int | getDSTSavings() Returns the amount of time to be added to local standard time
to get local wall clock time.
The default implementation always returns 3600000 milliseconds
(i.e., one hour) if this time zone observes Daylight Saving
Time. | public static synchronized TimeZone | getDefault() Gets the default TimeZone for this host. | final public String | getDisplayName() Returns a name of this time zone suitable for presentation to the user
in the default locale. | final public String | getDisplayName(Locale locale) Returns a name of this time zone suitable for presentation to the user
in the specified locale.
This method returns the long generic name.
If the display name is not available for the locale,
a fallback based on the country, city, or time zone id will be used.
Parameters: locale - the locale in which to supply the display name. | final public String | getDisplayName(ULocale locale) Returns a name of this time zone suitable for presentation to the user
in the specified locale.
This method returns the long name, not including daylight savings.
If the display name is not available for the locale,
a fallback based on the country, city, or time zone id will be used.
Parameters: locale - the ulocale in which to supply the display name. | final public String | getDisplayName(boolean daylight, int style) Returns a name of this time zone suitable for presentation to the user
in the default locale. | public 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.
If the display name is not available for the locale,
then this method returns a string in the format
GMT[+-]hh:mm .
Parameters: daylight - if true, return the daylight savings name. Parameters: style - either LONG or SHORT Parameters: locale - the locale in which to supply the display name. | public String | getDisplayName(boolean daylight, int style, ULocale locale) Returns a name of this time zone suitable for presentation to the user
in the specified locale.
If the display name is not available for the locale,
then this method returns a string in the format
GMT[+-]hh:mm .
Parameters: daylight - if true, return the daylight savings name. Parameters: style - either LONG or SHORT Parameters: locale - the locale in which to supply the display name. | public static String | getEquivalentID(String id, int index) Returns an ID in the equivalency group that
includes the given ID. | public String | getID() Gets the ID of this time zone. | abstract public 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. | public int | getOffset(long date) Returns the offset of this time zone from UTC at the specified
date. | public void | getOffset(long date, boolean local, int[] offsets) Returns the time zone raw and GMT offset for the given moment
in time. | abstract public int | getRawOffset() Gets unmodified offset, NOT modified in case of daylight savings. | public static synchronized TimeZone | getTimeZone(String ID) Gets the TimeZone for the given ID.
Parameters: ID - the ID for a TimeZone , either an abbreviationsuch as "PST", a full name such as "America/Los_Angeles", or a customID such as "GMT-8:00". | public boolean | hasSameRules(TimeZone other) Returns true if this zone has the same rule and offset as another zone.
That is, if this zone differs only in ID, if at all. | public int | hashCode() Return the hash code. | abstract public boolean | inDaylightTime(Date date) Queries if the given date is in daylight savings time in
this time zone.
Parameters: date - the given Date. | public static synchronized void | setDefault(TimeZone tz) Sets the TimeZone that is
returned by the getDefault method. | public void | setID(String ID) Sets the time zone ID. | abstract public void | setRawOffset(int offsetMillis) Sets the base time zone offset to GMT. | abstract public boolean | useDaylightTime() Queries if this time zone uses daylight savings time. |
GREGORIAN_MONTH_COUNT | final static int[][] GREGORIAN_MONTH_COUNT(Code) | | For each month, the days in a non-leap year before the start
the of month, and the days in a leap year before the start of
the month.
TODO: This duplicates data in Calendar.java; clean up and
consolidate in ICU 3.0.
|
LONG | final public static int LONG(Code) | | A style specifier for getDisplayName() indicating
a long name, such as "Pacific Standard Time."
See Also: TimeZone.SHORT |
MILLIS_PER_DAY | final protected static int MILLIS_PER_DAY(Code) | | The number of milliseconds in one day.
|
MILLIS_PER_HOUR | final protected static int MILLIS_PER_HOUR(Code) | | The number of milliseconds in an hour.
|
SHORT | final public static int SHORT(Code) | | A style specifier for getDisplayName() indicating
a short name, such as "PST."
See Also: TimeZone.LONG |
TimeZone | public TimeZone()(Code) | | Default constructor. (For invocation by subclass constructors,
typically implicit.)
|
computeGregorianFields | static void computeGregorianFields(long day, int fields)(Code) | | Compute the Gregorian calendar year, month, and day of month
from the epoch day, and return them in the given array.
TODO: This duplicates a method in Calendar; clean up and
consolidate in ICU 3.0.
|
countEquivalentIDs | public static int countEquivalentIDs(String id)(Code) | | Returns the number of IDs in the equivalency group that
includes the given ID. An equivalency group contains zones
that have the same GMT offset and rules.
The returned count includes the given ID; it is always >= 1
for valid IDs. The given ID must be a system time zone. If it
is not, returns zero.
Parameters: id - a system time zone ID the number of zones in the equivalency group containing'id', or zero if 'id' is not a valid system ID See Also: TimeZone.getEquivalentID |
equals | public boolean equals(Object obj)(Code) | | Return true if obj is a TimeZone with the same class and ID as this.
true if obj is a TimeZone with the same class and ID as this Parameters: obj - the object to compare against |
floorDivide | static long floorDivide(long numerator, long denominator)(Code) | | Divide two long integers, returning the floor of the quotient.
Unlike the built-in division, this is mathematically well-behaved.
E.g., -1/4 => 0
but floorDivide(-1,4) => -1.
TODO: This duplicates a method in Calendar; clean up and
consolidate in ICU 3.0.
Parameters: numerator - the numerator Parameters: denominator - a divisor which must be > 0 the floor of the quotient. |
floorDivide | static int floorDivide(long numerator, int denominator, int[] remainder)(Code) | | Divide two integers, returning the floor of the quotient, and
the modulus remainder.
Unlike the built-in division, this is mathematically well-behaved.
E.g., -1/4 => 0 and -1%4 => -1,
but floorDivide(-1,4) => -1 with remainder[0] => 3.
TODO: This duplicates a method in Calendar; clean up and
consolidate in ICU 3.0.
Parameters: numerator - the numerator Parameters: denominator - a divisor which must be > 0 Parameters: remainder - an array of at least one element in which the valuenumerator mod denominator is returned. Unlike numerator% denominator , this will always be non-negative. the floor of the quotient. |
getAvailableIDs | public static String[] getAvailableIDs(int rawOffset)(Code) | | Return a new String array containing all system TimeZone IDs
with the given raw offset from GMT. These IDs may be passed to
get() to construct the corresponding TimeZone
object.
Parameters: rawOffset - the offset in milliseconds from GMT an array of IDs for system TimeZones with the givenraw offset. If there are none, return a zero-length array. |
getAvailableIDs | public static String[] getAvailableIDs(String country)(Code) | | Return a new String array containing all system TimeZone IDs
associated with the given country. These IDs may be passed to
get() to construct the corresponding TimeZone
object.
Parameters: country - a two-letter ISO 3166 country code, or null to return zones not associated with any country an array of IDs for system TimeZones in the givencountry. If there are none, return a zero-length array. |
getAvailableIDs | public static String[] getAvailableIDs()(Code) | | Return a new String array containing all system TimeZone IDs.
These IDs (and only these IDs) may be passed to
get() to construct the corresponding TimeZone
object.
an array of all system TimeZone IDs |
getDSTSavings | public int getDSTSavings()(Code) | | Returns the amount of time to be added to local standard time
to get local wall clock time.
The default implementation always returns 3600000 milliseconds
(i.e., one hour) if this time zone observes Daylight Saving
Time. Otherwise, 0 (zero) is returned.
If an underlying TimeZone implementation subclass supports
historical Daylight Saving Time changes, this method returns
the known latest daylight saving value.
the amount of saving time in milliseconds |
getDefault | public static synchronized TimeZone getDefault()(Code) | | Gets the default TimeZone for this host.
The source of the default TimeZone
may vary with implementation.
a default TimeZone . |
getDisplayName | final public String getDisplayName()(Code) | | Returns a name of this time zone suitable for presentation to the user
in the default locale.
This method returns the long generic name.
If the display name is not available for the locale,
a fallback based on the country, city, or time zone id will be used.
the human-readable name of this time zone in the default locale. |
getDisplayName | final public String getDisplayName(Locale locale)(Code) | | Returns a name of this time zone suitable for presentation to the user
in the specified locale.
This method returns the long generic name.
If the display name is not available for the locale,
a fallback based on the country, city, or time zone id will be used.
Parameters: locale - the locale in which to supply the display name. the human-readable name of this time zone in the given localeor in the default locale if the given locale is not recognized. |
getDisplayName | final public String getDisplayName(ULocale locale)(Code) | | Returns a name of this time zone suitable for presentation to the user
in the specified locale.
This method returns the long name, not including daylight savings.
If the display name is not available for the locale,
a fallback based on the country, city, or time zone id will be used.
Parameters: locale - the ulocale in which to supply the display name. the human-readable name of this time zone in the given localeor in the default ulocale if the given ulocale is not recognized. |
getDisplayName | final public String getDisplayName(boolean daylight, int style)(Code) | | Returns a name of this time zone suitable for presentation to the user
in the default locale.
If the display name is not available for the locale,
then this method returns a string in the format
GMT[+-]hh:mm .
Parameters: daylight - if true, return the daylight savings name. Parameters: style - either LONG or SHORT the human-readable name of this time zone in the default locale. |
getDisplayName | public String getDisplayName(boolean daylight, int style, Locale locale)(Code) | | Returns a name of this time zone suitable for presentation to the user
in the specified locale.
If the display name is not available for the locale,
then this method returns a string in the format
GMT[+-]hh:mm .
Parameters: daylight - if true, return the daylight savings name. Parameters: style - either LONG or SHORT Parameters: locale - the locale in which to supply the display name. the human-readable name of this time zone in the given localeor in the default locale if the given locale is not recognized. exception: IllegalArgumentException - style is invalid. |
getDisplayName | public String getDisplayName(boolean daylight, int style, ULocale locale)(Code) | | Returns a name of this time zone suitable for presentation to the user
in the specified locale.
If the display name is not available for the locale,
then this method returns a string in the format
GMT[+-]hh:mm .
Parameters: daylight - if true, return the daylight savings name. Parameters: style - either LONG or SHORT Parameters: locale - the locale in which to supply the display name. the human-readable name of this time zone in the given localeor in the default locale if the given locale is not recognized. exception: IllegalArgumentException - style is invalid. |
getEquivalentID | public static String getEquivalentID(String id, int index)(Code) | | Returns an ID in the equivalency group that
includes the given ID. An equivalency group contains zones
that have the same GMT offset and rules.
The given index must be in the range 0..n-1, where n is the
value returned by countEquivalentIDs(id) . For
some value of 'index', the returned value will be equal to the
given id. If the given id is not a valid system time zone, or
if 'index' is out of range, then returns an empty string.
Parameters: id - a system time zone ID Parameters: index - a value from 0 to n-1, where n is the valuereturned by countEquivalentIDs(id) the ID of the index-th zone in the equivalency groupcontaining 'id', or an empty string if 'id' is not a validsystem ID or 'index' is out of range See Also: TimeZone.countEquivalentIDs |
getID | public String getID()(Code) | | Gets the ID of this time zone.
the ID of this time zone. |
getOffset | abstract public int getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds)(Code) | | Gets the time zone 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. Parameters: year - the year in the given date. Parameters: month - the month in the given date.Month is 0-based. e.g., 0 for January. Parameters: day - the day-in-month of the given date. Parameters: dayOfWeek - the day-of-week of the given date. Parameters: milliseconds - the millis in day in standard local time. the offset to add *to* GMT to get local time. |
getOffset | public int getOffset(long date)(Code) | | Returns the offset of this time zone from UTC at the specified
date. If Daylight Saving Time is in effect at the specified
date, the offset value is adjusted with the amount of daylight
saving.
Parameters: date - the date represented in milliseconds since January 1, 1970 00:00:00 GMT the amount of time in milliseconds to add to UTC to get local time. See Also: Calendar.ZONE_OFFSET See Also: Calendar.DST_OFFSET See Also: TimeZone.getOffset(long,boolean,int[]) |
getOffset | public void getOffset(long date, boolean local, int[] offsets)(Code) | | Returns the time zone raw and GMT offset for the given moment
in time. Upon return, local-millis = GMT-millis + rawOffset +
dstOffset. All computations are performed in the proleptic
Gregorian calendar. The default implementation in the TimeZone
class delegates to the 8-argument getOffset().
Parameters: date - moment in time for which to return offsets, inunits of milliseconds from January 1, 1970 0:00 GMT, either GMTtime or local wall time, depending on `local'. Parameters: local - if true, `date' is local wall time; otherwise itis in GMT time. Parameters: offsets - output parameter to receive the raw offset, thatis, the offset not including DST adjustments, in offsets[0],and the DST offset, that is, the offset to be added to`rawOffset' to obtain the total offset between local and GMTtime, in offsets[1]. If DST is not in effect, the DST offset iszero; otherwise it is a positive value, typically one hour. |
getRawOffset | abstract public int getRawOffset()(Code) | | Gets unmodified offset, NOT modified in case of daylight savings.
This is the offset to add *to* UTC to get local time.
the unmodified offset to add *to* UTC to get local time. |
getTimeZone | public static synchronized TimeZone getTimeZone(String ID)(Code) | | Gets the TimeZone for the given ID.
Parameters: ID - the ID for a TimeZone , either an abbreviationsuch as "PST", a full name such as "America/Los_Angeles", or a customID such as "GMT-8:00". Note that the support of abbreviations isfor JDK 1.1.x compatibility only and full names should be used. the specified TimeZone , or the GMT zone if the given IDcannot be understood. |
hasSameRules | public boolean hasSameRules(TimeZone other)(Code) | | Returns true if this zone has the same rule and offset as another zone.
That is, if this zone differs only in ID, if at all. Returns false
if the other zone is null.
Parameters: other - the TimeZone object to be compared with true if the other zone is not null and is the same as this one,with the possible exception of the ID |
hashCode | public int hashCode()(Code) | | Return the hash code.
the hash code |
inDaylightTime | abstract public boolean inDaylightTime(Date date)(Code) | | Queries if the given date is in daylight savings time in
this time zone.
Parameters: date - the given Date. true if the given date is in daylight savings time,false, otherwise. |
setDefault | public static synchronized void setDefault(TimeZone tz)(Code) | | Sets the TimeZone that is
returned by the getDefault method. If zone
is null, reset the default to the value it had originally when the
VM first started.
Parameters: tz - the new default time zone |
setID | public void setID(String ID)(Code) | | Sets the time zone ID. This does not change any other data in
the time zone object.
Parameters: ID - the new time zone ID. |
setRawOffset | abstract public void setRawOffset(int offsetMillis)(Code) | | 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. |
useDaylightTime | abstract public boolean useDaylightTime()(Code) | | Queries if this time zone uses daylight savings time.
true if this time zone uses daylight savings time,false, otherwise. |
|
|