Top Description Fields Constructors Methods
com.ibm.icu.impl

public Class JavaTimeZone

extends TimeZone
Class Inheritance
Imports
java.io.IOException, .ObjectInputStream, java.lang.reflect.InvocationTargetException, .Method, java.util.Date, .TreeSet, com.ibm.icu.util.TimeZone

JavaTimeZone inherits com.ibm.icu.util.TimeZone and wraps java.util.TimeZone. We used to have JDKTimeZone which wrapped Java TimeZone and used it as primary TimeZone implementation until ICU4J 3.4.1. This class works exactly like JDKTimeZone and allows ICU users who use ICU4J and JDK date/time/calendar services in mix to maintain only JDK timezone rules. This TimeZone subclass is returned by the TimeZone factory method getTimeZone(String) when the default timezone type in TimeZone class is TimeZone.TIMEZONE_JDK.

Field Summary

Modifier and TypeField and Description
private static final TreeSet<String>
private transient volatile boolean
private transient Calendar
private TimeZone
private static Method
private static final long
Inherited from com.ibm.icu.util.TimeZone:
GENERIC_LOCATIONGMT_ZONELONGLONG_GENERICLONG_GMTSHORTSHORT_COMMONLY_USEDSHORT_GENERICSHORT_GMTTIMEZONE_ICUTIMEZONE_JDKUNKNOWN_ZONEUNKNOWN_ZONE_ID

Constructor Summary

AccessConstructor and Description
public
JavaTimeZone()

Constructs a JavaTimeZone with the default Java TimeZone

public
JavaTimeZone(TimeZone
the Java TimeZone
jtz
,
String
the ID of the zone. if null, the zone ID is initialized by the given Java TimeZone's ID.
id
)

Constructs a JavaTimeZone with the specified Java TimeZone and ID.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides com.ibm.icu.util.TimeZone.clone.

Overrides clone.
public TimeZone
public static JavaTimeZone

Returns:

An instance of JavaTimeZone for the given ID, or null when the ID cannot be understood.
createTimeZone
(String
A timezone ID, either a system ID or a custom ID.
id
)

Creates an instance of JavaTimeZone with the given timezone ID.

public TimeZone
public int
getDSTSavings()

Overrides com.ibm.icu.util.TimeZone.getDSTSavings.

Returns the amount of time to be added to local standard time to get local wall clock time.
public int
getOffset(int
the era of the given date.
era
,
int
the year in the given date.
year
,
int
the month in the given date. Month is 0-based. e.g., 0 for January.
month
,
int
the day-in-month of the given date.
day
,
int
the day-of-week of the given date.
dayOfWeek
,
int
the millis in day in standard local time.
milliseconds
)

Implements abstract com.ibm.icu.util.TimeZone.getOffset.

Gets the time zone offset, for current date, modified in case of daylight savings.
public void
getOffset(long
moment in time for which to return offsets, in units of milliseconds from January 1, 1970 0:00 GMT, either GMT time or local wall time, depending on local.
date
,
boolean
if true, date is local wall time; otherwise it is in GMT time.
local
,
int[]
output parameter to receive the raw offset, that is, 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 GMT time, in offsets[1]. If DST is not in effect, the DST offset is zero; otherwise it is a positive value, typically one hour.
offsets
)

Overrides com.ibm.icu.util.TimeZone.getOffset.

Returns the time zone raw and GMT offset for the given moment in time.
public int
getRawOffset()

Implements abstract com.ibm.icu.util.TimeZone.getRawOffset.

Gets unmodified offset, NOT modified in case of daylight savings.
public int
hashCode()

Overrides com.ibm.icu.util.TimeZone.hashCode.

Overrides hashCode.
public boolean
inDaylightTime(Date
the given Date.
date
)

Implements abstract com.ibm.icu.util.TimeZone.inDaylightTime.

Queries if the given date is in daylight savings time in this time zone.
public boolean
isFrozen()

Overrides com.ibm.icu.util.TimeZone.isFrozen.

Implements com.ibm.icu.util.Freezable.isFrozen.

Determines whether the object has been frozen or not.
public boolean
observesDaylightTime()

Overrides com.ibm.icu.util.TimeZone.observesDaylightTime.

Queries if this time zone is in daylight saving time or will observe daylight saving time at any future time.
private void
public void
setRawOffset(int
the given base time zone offset to GMT.
offsetMillis
)

Implements abstract com.ibm.icu.util.TimeZone.setRawOffset.

Sets the base time zone offset to GMT.
public TimeZone
public boolean
useDaylightTime()

Implements abstract com.ibm.icu.util.TimeZone.useDaylightTime.

Queries if this time zone uses daylight savings time.
Inherited from com.ibm.icu.util.TimeZone:
countEquivalentIDsequalsforLocaleOrDefaultforULocaleOrDefaultgetAvailableIDsgetAvailableIDsgetAvailableIDsgetAvailableIDsgetCanonicalIDgetCanonicalIDgetDefaultgetDefaultTimeZoneTypegetDisplayNamegetDisplayNamegetDisplayNamegetDisplayNamegetDisplayNamegetDisplayNamegetEquivalentIDgetFrozenTimeZonegetIanaIDgetIDgetIDForWindowsIDgetOffsetgetRegiongetTimeZonegetTimeZonegetTZDataVersiongetWindowsIDhasSameRulessetDefaultsetDefaultTimeZoneTypesetICUDefaultsetID

Field Detail

AVAILABLESETback to summary
private static final TreeSet<String> AVAILABLESET
isFrozenback to summary
private transient volatile boolean isFrozen
javacalback to summary
private transient Calendar javacal
javatzback to summary
private TimeZone javatz
mObservesDaylightTimeback to summary
private static Method mObservesDaylightTime
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.ibm.icu.util.TimeZone.serialVersionUID.

Constructor Detail

JavaTimeZoneback to summary
public JavaTimeZone()

Constructs a JavaTimeZone with the default Java TimeZone

JavaTimeZoneback to summary
public JavaTimeZone(TimeZone jtz, String id)

Constructs a JavaTimeZone with the specified Java TimeZone and ID.

Parameters
jtz:TimeZone

the Java TimeZone

id:String

the ID of the zone. if null, the zone ID is initialized by the given Java TimeZone's ID.

Method Detail

cloneback to summary
public Object clone()

Overrides com.ibm.icu.util.TimeZone.clone.

Doc from com.ibm.icu.util.TimeZone.clone.

Overrides clone.

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
cloneAsThawedback to summary
public TimeZone cloneAsThawed()

Overrides com.ibm.icu.util.TimeZone.cloneAsThawed.

Implements com.ibm.icu.util.Freezable.cloneAsThawed.

Doc from com.ibm.icu.util.TimeZone.cloneAsThawed.

Provides for the clone operation. Any clone is initially unfrozen.

Annotations
@Override
createTimeZoneback to summary
public static JavaTimeZone createTimeZone(String id)

Creates an instance of JavaTimeZone with the given timezone ID.

Parameters
id:String

A timezone ID, either a system ID or a custom ID.

Returns:JavaTimeZone

An instance of JavaTimeZone for the given ID, or null when the ID cannot be understood.

freezeback to summary
public TimeZone freeze()

Overrides com.ibm.icu.util.TimeZone.freeze.

Implements com.ibm.icu.util.Freezable.freeze.

Doc from com.ibm.icu.util.TimeZone.freeze.

Freezes the object.

Returns:TimeZone

Doc from com.ibm.icu.util.Freezable.freeze.

the object itself.

Annotations
@Override
getDSTSavingsback to summary
public int getDSTSavings()

Overrides com.ibm.icu.util.TimeZone.getDSTSavings.

Doc from com.ibm.icu.util.TimeZone.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. 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.

Returns:int

the amount of saving time in milliseconds

Annotations
@Override
getOffsetback to summary
public int getOffset(int era, int year, int month, int day, int dayOfWeek, int milliseconds)

Implements abstract com.ibm.icu.util.TimeZone.getOffset.

Doc from com.ibm.icu.util.TimeZone.getOffset.

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:int

the era of the given date.

year:int

the year in the given date.

month:int

the month in the given date. Month is 0-based. e.g., 0 for January.

day:int

the day-in-month of the given date.

dayOfWeek:int

the day-of-week of the given date.

milliseconds:int

the millis in day in standard local time.

Returns:int

the offset to add to GMT to get local time.

Annotations
@Override
getOffsetback to summary
public void getOffset(long date, boolean local, int[] offsets)

Overrides com.ibm.icu.util.TimeZone.getOffset.

Doc from com.ibm.icu.util.TimeZone.getOffset.

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:long

moment in time for which to return offsets, in units of milliseconds from January 1, 1970 0:00 GMT, either GMT time or local wall time, depending on local.

local:boolean

if true, date is local wall time; otherwise it is in GMT time.

offsets:int[]

output parameter to receive the raw offset, that is, 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 GMT time, in offsets[1]. If DST is not in effect, the DST offset is zero; otherwise it is a positive value, typically one hour.

Annotations
@Override
getRawOffsetback to summary
public int getRawOffset()

Implements abstract com.ibm.icu.util.TimeZone.getRawOffset.

Doc from com.ibm.icu.util.TimeZone.getRawOffset.

Gets unmodified offset, NOT modified in case of daylight savings. This is the offset to add to UTC to get local time.

Returns:int

the unmodified offset to add to UTC to get local time.

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides com.ibm.icu.util.TimeZone.hashCode.

Doc from com.ibm.icu.util.TimeZone.hashCode.

Overrides hashCode.

Returns:int

a hash code value for this object.

Annotations
@Override
inDaylightTimeback to summary
public boolean inDaylightTime(Date date)

Implements abstract com.ibm.icu.util.TimeZone.inDaylightTime.

Doc from com.ibm.icu.util.TimeZone.inDaylightTime.

Queries if the given date is in daylight savings time in this time zone.

Parameters
date:Date

the given Date.

Returns:boolean

true if the given date is in daylight savings time, false, otherwise.

Annotations
@Override
isFrozenback to summary
public boolean isFrozen()

Overrides com.ibm.icu.util.TimeZone.isFrozen.

Implements com.ibm.icu.util.Freezable.isFrozen.

Doc from com.ibm.icu.util.TimeZone.isFrozen.

Determines whether the object has been frozen or not.

Annotations
@Override
observesDaylightTimeback to summary
public boolean observesDaylightTime()

Overrides com.ibm.icu.util.TimeZone.observesDaylightTime.

Doc from com.ibm.icu.util.TimeZone.observesDaylightTime.

Queries if this time zone is in daylight saving time or will observe daylight saving time at any future time.

The default implementation in this class returns true if useDaylightTime() or inDaylightTime(new Date()) returns true.

Note

This method was added for java.util.TimeZone compatibility support. The java.util.TimeZone#useDaylightTime() method only checks the last known rule(s), therefore it may return false even the zone observes daylight saving time currently. java.util.TimeZone added observesDaylightTime() to resolve the issue. In ICU, useDaylightTime() works differently. The ICU implementation checks if the zone uses daylight saving time in the current calendar year. Therefore, it will never return false if daylight saving time is currently used.

ICU's TimeZone subclass implementations override this method to support the same behavior with java.util.TimeZone#observesDaylightTime(). Unlike useDaylightTime(), the implementation does not take past daylight saving time into account, so that this method may return false even when useDaylightTime() returns true.

Returns:boolean

true if this time zone is in daylight saving time or will observe daylight saving time at any future time.

Annotations
@Override
readObjectback to summary
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
setRawOffsetback to summary
public void setRawOffset(int offsetMillis)

Implements abstract com.ibm.icu.util.TimeZone.setRawOffset.

Doc from com.ibm.icu.util.TimeZone.setRawOffset.

Sets the base time zone offset to GMT. This is the offset to add to UTC to get local time.

Parameters
offsetMillis:int

the given base time zone offset to GMT.

Annotations
@Override
unwrapback to summary
public TimeZone unwrap()
useDaylightTimeback to summary
public boolean useDaylightTime()

Implements abstract com.ibm.icu.util.TimeZone.useDaylightTime.

Doc from com.ibm.icu.util.TimeZone.useDaylightTime.

Queries if this time zone uses daylight savings time.

Returns:boolean

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

Note

The default implementation of ICU TimeZone uses the tz database, which supports historic rule changes, for system time zones. With the implementation, there are time zones that used daylight savings time in the past, but no longer used currently. For example, Asia/Tokyo has never used daylight savings time since 1951. Most clients would expect that this method to return false for such case. The default implementation of this method returns true when the time zone uses daylight savings time in the current (Gregorian) calendar year.

Annotations
@Override