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

public Class SimpleTimeZone

extends BasicTimeZone
Class Inheritance
Imports
java.io.IOException, java.util.Date, com.ibm.icu.impl.Grego

ICU Enhancement

This class is ICU's replacement for java.util.SimpleTimeZone.

ICU

Methods, fields, and other functionality specific to ICU are labeled 'ICU'.

SimpleTimeZone is a concrete subclass of TimeZone that represents a time zone for use with a Gregorian calendar. This class does not handle historical changes.

Use a negative value for dayOfWeekInMonth to indicate that SimpleTimeZone should count from the end of the month backwards. For example, if Daylight Savings Time starts or ends at the last Sunday in a month, use dayOfWeekInMonth = -1 along with dayOfWeek = Calendar.SUNDAY to specify the rule.

Author
Deborah Goldsmith, Mark Davis, Chen-Lieh Huang, Alan Liu
ICU Status
Stable since ICU 2.0.
See Also
Calendar, GregorianCalendar, TimeZone

Field Summary

Modifier and TypeField and Description
private static final int
private static final int
private static final int
private static final int
private int
private transient AnnualTimeZoneRule
private int
private int
private int
private int
private int
private int
private transient TimeZoneTransition
private transient InitialTimeZoneRule
private transient volatile boolean
private int
private static final long
public static final int
STANDARD_TIME

Constant for a mode of start or end time specified as local standard time.

private int
private int
private int
private int
private int
private int
private int
private static final byte[]
private transient AnnualTimeZoneRule
private transient boolean
private boolean
public static final int
UTC_TIME

Constant for a mode of start or end time specified as UTC.

public static final int
WALL_TIME

Constant for a mode of start or end time specified as local wall time.

private STZInfo
Inherited from com.ibm.icu.util.BasicTimeZone:
FORMER_LATTER_MASKLOCAL_DSTLOCAL_FORMERLOCAL_LATTERLOCAL_STDSTD_DST_MASK

Constructor Summary

AccessConstructor and Description
public
SimpleTimeZone(int
The given base time zone offset to GMT.
rawOffset
,
String
The time zone ID which is obtained from TimeZone.getAvailableIDs.
ID
)

Constructs a SimpleTimeZone with the given base time zone offset from GMT and time zone ID. Timezone IDs can be obtained from TimeZone.getAvailableIDs.

public
SimpleTimeZone(int
The given base time zone offset to GMT.
rawOffset
,
String
The time zone ID which is obtained from TimeZone.getAvailableIDs.
ID
,
int
The daylight savings starting month. Month is 0-based. eg, 0 for January.
startMonth
,
int
The daylight savings starting day-of-week-in-month. Please see the member description for an example.
startDay
,
int
The daylight savings starting day-of-week. Please see the member description for an example.
startDayOfWeek
,
int
The daylight savings starting time in local wall time, which is standard time in this case. Please see the member description for an example.
startTime
,
int
The daylight savings ending month. Month is 0-based. eg, 0 for January.
endMonth
,
int
The daylight savings ending day-of-week-in-month. Please see the member description for an example.
endDay
,
int
The daylight savings ending day-of-week. Please see the member description for an example.
endDayOfWeek
,
int
The daylight savings ending time in local wall time, which is daylight time in this case. Please see the member description for an example.
endTime
)

Constructs a SimpleTimeZone with the given base time zone offset from GMT, time zone ID, time to start and end the daylight time.

public
SimpleTimeZone(int
The given base time zone offset to GMT.
rawOffset
,
String
The time zone ID which is obtained from TimeZone.getAvailableIDs.
ID
,
int
The daylight savings starting month. Month is 0-based. eg, 0 for January.
startMonth
,
int
The daylight savings starting day-of-week-in-month. Please see the member description for an example.
startDay
,
int
The daylight savings starting day-of-week. Please see the member description for an example.
startDayOfWeek
,
int
The daylight savings starting time in local wall time, which is standard time in this case. Please see the member description for an example.
startTime
,
int
The mode of the start time specified by startTime.
startTimeMode
,
int
The daylight savings ending month. Month is 0-based. eg, 0 for January.
endMonth
,
int
The daylight savings ending day-of-week-in-month. Please see the member description for an example.
endDay
,
int
The daylight savings ending day-of-week. Please see the member description for an example.
endDayOfWeek
,
int
The daylight savings ending time in local wall time, which is daylight time in this case. Please see the member description for an example.
endTime
,
int
The mode of the end time specified by endTime.
endTimeMode
,
int
The amount of time in ms saved during DST.
dstSavings
)

Constructs a SimpleTimeZone with the given base time zone offset from GMT, time zone ID, time and its mode to start and end the daylight time.

public
SimpleTimeZone(int
The given base time zone offset to GMT.
rawOffset
,
String
The time zone ID which is obtained from TimeZone.getAvailableIDs.
ID
,
int
The daylight savings starting month. Month is 0-based. eg, 0 for January.
startMonth
,
int
The daylight savings starting day-of-week-in-month. Please see the member description for an example.
startDay
,
int
The daylight savings starting day-of-week. Please see the member description for an example.
startDayOfWeek
,
int
The daylight savings starting time in local wall time, which is standard time in this case. Please see the member description for an example.
startTime
,
int
The daylight savings ending month. Month is 0-based. eg, 0 for January.
endMonth
,
int
The daylight savings ending day-of-week-in-month. Please see the member description for an example.
endDay
,
int
The daylight savings ending day-of-week. Please see the member description for an example.
endDayOfWeek
,
int
The daylight savings ending time in local wall time, which is daylight time in this case. Please see the member description for an example.
endTime
,
int
The amount of time in ms saved during DST.
dstSavings
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

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

Overrides clone.
public TimeZone
private int

Returns:

1 if the date is after the rule date, -1 if the date is before the rule date, or 0 if the date is equal to the rule date.
compareToRule
(int month, int monthLen, int prevMonthLen, int dayOfMonth, int dayOfWeek, int millis, int millisDelta, int ruleMode, int ruleMonth, int ruleDayOfWeek, int ruleDay, int ruleMillis)

Compare a given date in the year to a rule.

private void
construct(int _raw, int _startMonth, int _startDay, int _startDayOfWeek, int _startTime, int _startTimeMode, int _endMonth, int _endDay, int _endDayOfWeek, int _endTime, int _endTimeMode, int _dst)

Internal construction method.

private void
decodeEndRule()

Decode the end rule and validate the parameters.

private void
private void
decodeStartRule()

Decode the start rule and validate the parameters.

public boolean

Returns:

true if obj is a SimpleTimeZone equivalent to this
equals
(Object
the reference object with which to compare.
obj
)

Overrides com.ibm.icu.util.TimeZone.equals.

Overrides equals.
public TimeZone
public int

Returns:

the number of milliseconds the time is advanced with respect to standard time when the daylight savings rules are in effect. Typically one hour (3600000). The amount could be negative, but not 0.
getDSTSavings
()

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

Returns the amount of time in ms that the clock is advanced during DST.
public TimeZoneTransition
getNextTransition(long
The base time.
base
,
boolean
Whether the base time is inclusive or not.
inclusive
)

Implements abstract com.ibm.icu.util.BasicTimeZone.getNextTransition.

ICU

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.
millis
)

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

Gets the time zone offset, for current date, modified in case of daylight savings.
public int
getOffset(int era, int year, int month, int day, int dayOfWeek, int millis, int monthLength)

Deprecated This API is ICU internal only.
private int
getOffset(int era, int year, int month, int day, int dayOfWeek, int millis, int monthLength, int prevMonthLength)

public void
getOffsetFromLocal(long date, BasicTimeZone.LocalOption nonExistingTimeOpt, BasicTimeZone.LocalOption duplicatedTimeOpt, int[] offsets)

Overrides com.ibm.icu.util.BasicTimeZone.getOffsetFromLocal.

ICU

public TimeZoneTransition
getPreviousTransition(long
The base time.
base
,
boolean
Whether the base time is inclusive or not.
inclusive
)

Implements abstract com.ibm.icu.util.BasicTimeZone.getPreviousTransition.

ICU

public int

Returns:

the raw offset
getRawOffset
()

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

Overrides TimeZone Gets the GMT offset for this time zone.
private STZInfo
public TimeZoneRule[]
public int

Returns:

a hash code value for this object.
hashCode
()

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

Overrides hashCode.
public boolean

Returns:

true if the given zone has the same rules and offset as this one
hasSameRules
(TimeZone
the TimeZone object to be compared with
othr
)

Overrides com.ibm.icu.util.TimeZone.hasSameRules.

Returns true if this zone has the same rules and offset as another zone.
private boolean
public boolean
inDaylightTime(Date
the given Date.
date
)

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

Overrides TimeZone Queries if the give date is in Daylight Saving Time.
private synchronized void
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
readObject(ObjectInputStream in)

Returns the java.util.SimpleTimeZone that this class wraps.

public void
setDSTSavings(int
the number of milliseconds the time is advanced with respect to standard time when the daylight savings rules are in effect. Typically one hour (+3600000). The amount could be negative, but not 0.
millisSavedDuringDST
)

Sets the amount of time in ms that the clock is advanced during DST.

public void
setEndRule(int
The daylight savings ending month. Month is 0-based. eg, 0 for January.
month
,
int
The daylight savings ending day-of-week-in-month. Please see the member description for an example.
dayOfWeekInMonth
,
int
The daylight savings ending day-of-week. Please see the member description for an example.
dayOfWeek
,
int
The daylight savings ending time in local wall time, which is daylight time in this case. Please see the member description for an example.
time
)

Sets the daylight savings ending rule.

public void
setEndRule(int
The month in which this rule occurs (0-based).
month
,
int
The date in that month (1-based).
dayOfMonth
,
int
The time of that day (number of millis after midnight) when DST ends in local wall time, which is daylight time in this case.
time
)

Sets the DST end rule to a fixed date within a month.

public void
setEndRule(int
The month in which this rule occurs (0-based).
month
,
int
A date within that month (1-based).
dayOfMonth
,
int
The day of the week on which this rule occurs.
dayOfWeek
,
int
The time of that day (number of millis after midnight) when DST ends in local wall time, which is daylight time in this case.
time
,
boolean
If true, this rule selects the first dayOfWeek on or after dayOfMonth. If false, this rule selects the last dayOfWeek on or before dayOfMonth.
after
)

Sets the DST end rule to a weekday before or after a give date within a month, e.g., the first Monday on or after the 8th.

private void
setEndRule(int month, int dayOfMonth, int dayOfWeek, int time, int mode, boolean after)

private void
setEndRule(int
the daylight savings ending month. Month is 0-based. eg, 0 for January.
month
,
int
the daylight savings ending day-of-week-in-month. See setStartRule() for a complete explanation.
dayOfWeekInMonth
,
int
the daylight savings ending day-of-week. See setStartRule() for a complete explanation.
dayOfWeek
,
int
the daylight savings ending time. Please see the member description for an example.
time
,
int mode)

Sets the daylight savings ending rule.

public void
setID(String
the new time zone ID.
ID
)

Overrides com.ibm.icu.util.TimeZone.setID.

Sets the time zone ID. This does not change any other data in the time zone object.
public void
setRawOffset(int
the raw offset of the time zone
offsetMillis
)

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

Overrides TimeZone Sets the base time zone offset to GMT.
public void
setStartRule(int
The daylight savings starting month. Month is 0-based. eg, 0 for January.
month
,
int
The daylight savings starting day-of-week-in-month. Please see the member description for an example.
dayOfWeekInMonth
,
int
The daylight savings starting day-of-week. Please see the member description for an example.
dayOfWeek
,
int
The daylight savings starting time in local wall time, which is standard time in this case. Please see the member description for an example.
time
)

Sets the daylight savings starting rule.

private void
setStartRule(int
the daylight savings starting month. Month is 0-based. eg, 0 for January.
month
,
int
the daylight savings starting day-of-week-in-month. Please see the member description for an example.
dayOfWeekInMonth
,
int
the daylight savings starting day-of-week. Please see the member description for an example.
dayOfWeek
,
int
the daylight savings starting time. Please see the member description for an example.
time
,
int mode)

Sets the daylight savings starting rule.

public void
setStartRule(int
The month in which this rule occurs (0-based).
month
,
int
The date in that month (1-based).
dayOfMonth
,
int
The time of that day (number of millis after midnight) when DST takes effect in local wall time, which is standard time in this case.
time
)

Sets the DST start rule to a fixed date within a month.

public void
setStartRule(int
The month in which this rule occurs (0-based).
month
,
int
A date within that month (1-based).
dayOfMonth
,
int
The day of the week on which this rule occurs.
dayOfWeek
,
int
The time of that day (number of millis after midnight) when DST takes effect in local wall time, which is standard time in this case.
time
,
boolean
If true, this rule selects the first dayOfWeek on or after dayOfMonth. If false, this rule selects the last dayOfWeek on or before dayOfMonth.
after
)

Sets the DST start rule to a weekday before or after a give date within a month, e.g., the first Monday on or after the 8th.

public void
setStartYear(int
The daylight savings starting year.
year
)

Sets the daylight savings starting year.

public String

Returns:

a string representation of this object
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this object.
public boolean
useDaylightTime()

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

Overrides TimeZone Queries if this time zone uses Daylight Saving Time.
Inherited from com.ibm.icu.util.BasicTimeZone:
getLocalOptionValuegetSimpleTimeZoneRulesNeargetTimeZoneRuleshasEquivalentTransitionshasEquivalentTransitions