dstSavings
A positive value indicating the amount of time saved during DST in
milliseconds.

private int

endDay
This field has two possible interpretations:
endMode == DOW_IN_MONTHendDay indicates the day of the month of
endMonth on which daylight
saving time ends, from 1 to 28, 30, or 31, depending on the
endMonth.

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

private int

startDay
This field has two possible interpretations:
startMode == DOW_IN_MONTHstartDay indicates the day of the month of
startMonth on which daylight
saving time starts, from 1 to 28, 30, or 31, depending on the
startMonth.

private int

startDayOfWeek
The day of the week on which daylight saving time starts.

equals(Object obj)Suppressed: Compares the equality of two SimpleTimeZone objects.

int

getDSTSavings()Enabled: Returns the amount of time in milliseconds that the clock is
advanced during daylight saving time.

int

getOffset(int era,
int year,
int month,
int day,
int dayOfWeek,
int millis)Enabled: Returns the difference in milliseconds between local time and
UTC, taking into account both the raw offset and the effect of
daylight saving, for the specified date and time.

setEndRule(int endMonth,
int endDay,
int endDayOfWeek,
int endTime,
boolean after)Enabled: Sets the daylight saving time end rule to a weekday before or after the given date within
a month, e.g., the first Monday on or after the 8th.

void

setRawOffset(int offsetMillis)Enabled: Sets the base time zone offset to GMT.

void

setStartRule(int startMonth,
int startDay,
int startTime)Enabled: Sets the daylight saving time start rule to a fixed date within a month.

setStartRule(int startMonth,
int startDay,
int startDayOfWeek,
int startTime,
boolean after)Enabled: Sets the daylight saving time start rule to a weekday before or after the given date within
a month, e.g., the first Monday on or after the 8th.

startMonth

The month in which daylight saving time starts. This value must be
between Calendar.JANUARY and
Calendar.DECEMBER inclusive. This value must not equal
endMonth.

If useDaylight is false, this value is ignored.

startDay

private int startDay

This field has two possible interpretations:

startMode == DOW_IN_MONTH

startDay indicates the day of the month of
startMonth on which daylight
saving time starts, from 1 to 28, 30, or 31, depending on the
startMonth.

startMode != DOW_IN_MONTH

startDay indicates which startDayOfWeek in th
month startMonth daylight
saving time starts on. For example, a value of +1 and a
startDayOfWeek of Calendar.SUNDAY indicates the
first Sunday of startMonth. Likewise, +2 would indicate the
second Sunday, and -1 the last Sunday. A value of 0 is illegal.

If useDaylight is false, this value is ignored.

startDayOfWeek

private int startDayOfWeek

The day of the week on which daylight saving time starts. This value
must be between Calendar.SUNDAY and
Calendar.SATURDAY inclusive.

If useDaylight is false or
startMode == DAY_OF_MONTH, this value is ignored.

startTime

private int startTime

The time in milliseconds after midnight at which daylight saving
time starts. This value is expressed as wall time, standard time,
or UTC time, depending on the setting of startTimeMode.

If useDaylight is false, this value is ignored.

startTimeMode

private int startTimeMode

The format of startTime, either WALL_TIME, STANDARD_TIME, or UTC_TIME.

Since:

1.3

endMonth

private int endMonth

The month in which daylight saving time ends. This value must be
between Calendar.JANUARY and
Calendar.UNDECIMBER. This value must not equal
startMonth.

If useDaylight is false, this value is ignored.

endDay

private int endDay

This field has two possible interpretations:

endMode == DOW_IN_MONTH

endDay indicates the day of the month of
endMonth on which daylight
saving time ends, from 1 to 28, 30, or 31, depending on the
endMonth.

endMode != DOW_IN_MONTH

endDay indicates which endDayOfWeek in th
month endMonth daylight
saving time ends on. For example, a value of +1 and a
endDayOfWeek of Calendar.SUNDAY indicates the
first Sunday of endMonth. Likewise, +2 would indicate the
second Sunday, and -1 the last Sunday. A value of 0 is illegal.

If useDaylight is false, this value is ignored.

endDayOfWeek

private int endDayOfWeek

The day of the week on which daylight saving time ends. This value
must be between Calendar.SUNDAY and
Calendar.SATURDAY inclusive.

If useDaylight is false or
endMode == DAY_OF_MONTH, this value is ignored.

endTime

private int endTime

The time in milliseconds after midnight at which daylight saving
time ends. This value is expressed as wall time, standard time,
or UTC time, depending on the setting of endTimeMode.

If useDaylight is false, this value is ignored.

endTimeMode

private int endTimeMode

The format of endTime, either WALL_TIME, STANDARD_TIME, or UTC_TIME.

Since:

1.3

startYear

private int startYear

The year in which daylight saving time is first observed. This is an AD
value. If this value is less than 1 then daylight saving time is observed
for all AD years.

If useDaylight is false, this value is ignored.

rawOffset

private int rawOffset

The offset in milliseconds between this zone and GMT. Negative offsets
are to the west of Greenwich. To obtain local standard time,
add the offset to GMT time. To obtain local wall time it may also be
necessary to add dstSavings.

useDaylight

private boolean useDaylight

A boolean value which is true if and only if this zone uses daylight
saving time. If this value is false, several other fields are ignored.

millisPerHour

private static final int millisPerHour

millisPerDay

private static final int millisPerDay

monthLength

private final byte[] monthLength

This field was serialized in JDK 1.1, so we have to keep it that way
to maintain serialization compatibility. However, there's no need to
recreate the array each time we create a new time zone.

staticMonthLength

private static final byte[] staticMonthLength

staticLeapMonthLength

private static final byte[] staticLeapMonthLength

startMode

private int startMode

Variables specifying the mode of the start rule. Takes the following
values:

DOM_MODE

Exact day of week; e.g., March 1.

DOW_IN_MONTH_MODE

Day of week in month; e.g., last Sunday in March.

DOW_GE_DOM_MODE

Day of week after day of month; e.g., Sunday on or after March 15.

DOW_LE_DOM_MODE

Day of week before day of month; e.g., Sunday on or before March 15.

The setting of this field affects the interpretation of the
startDay field.

If useDaylight is false, this value is ignored.

Since:

1.1.4

endMode

private int endMode

Variables specifying the mode of the end rule. Takes the following
values:

DOM_MODE

Exact day of week; e.g., March 1.

DOW_IN_MONTH_MODE

Day of week in month; e.g., last Sunday in March.

DOW_GE_DOM_MODE

Day of week after day of month; e.g., Sunday on or after March 15.

DOW_LE_DOM_MODE

Day of week before day of month; e.g., Sunday on or before March 15.

The setting of this field affects the interpretation of the
endDay field.

If useDaylight is false, this value is ignored.

Since:

1.1.4

dstSavings

private int dstSavings

A positive value indicating the amount of time saved during DST in
milliseconds.
Typically one hour (3600000); sometimes 30 minutes (1800000).

If useDaylight is false, this value is ignored.

Since:

1.1.4

DOM_MODE

private static final int DOM_MODE

Constants specifying values of startMode and endMode.

DOW_IN_MONTH_MODE

private static final int DOW_IN_MONTH_MODE

DOW_GE_DOM_MODE

private static final int DOW_GE_DOM_MODE

DOW_LE_DOM_MODE

private static final int DOW_LE_DOM_MODE

WALL_TIME

public static final int WALL_TIME

Enabled: Constant for a mode of start or end time specified as wall clock
time. Wall clock time is standard time for the onset rule, and
daylight time for the end rule.

Since:

1.4

STANDARD_TIME

public static final int STANDARD_TIME

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

Since:

1.4

UTC_TIME

public static final int UTC_TIME

Enabled: Constant for a mode of start or end time specified as UTC. European
Union rules are specified as UTC time, for example.

Since:

1.4

serialVersionUID

static final long serialVersionUID

currentSerialVersion

static final int currentSerialVersion

serialVersionOnStream

private int serialVersionOnStream

The version of the serialized data on the stream. Possible values:

0 or not present on stream

JDK 1.1.3 or earlier.

1

JDK 1.1.4 or later. Includes three new fields: startMode,
endMode, and dstSavings.

2

JDK 1.3 or later. Includes two new fields: startTimeMode
and endTimeMode.

When streaming out this class, the most recent format
and the highest allowable serialVersionOnStream
is written.

SimpleTimeZone

Enabled: Constructs a SimpleTimeZone with the given base time zone offset from
GMT, time zone ID, and rules for starting and ending the daylight
time.
Both startTime and endTime are specified to be
represented in the wall clock time. The amount of daylight saving is
assumed to be 3600000 milliseconds (i.e., one hour). This constructor is
equivalent to:

SimpleTimeZone

Enabled: Constructs a SimpleTimeZone with the given base time zone offset from
GMT, time zone ID, and rules for starting and ending the daylight
time.
Both startTime and endTime are assumed to be
represented in the wall clock time. This constructor is equivalent to:

Enabled: Constructs a SimpleTimeZone with the given base time zone offset from
GMT, time zone ID, and rules for starting and ending the daylight
time.
This constructor takes the full set of the start and end rules
parameters, including modes of startTime and
endTime. The mode specifies either wall
time or standard time or UTC
time.

Parameters:

rawOffset - The given base time zone offset from GMT.

ID - The time zone ID which is given to this object.

startMonth - The daylight saving time starting month. Month is
a MONTH field
value (0-based. e.g., 0 for January).

startDay - The day of the month on which the daylight saving time starts.
See the class description for the special cases of this parameter.

startDayOfWeek - The daylight saving time starting day-of-week.
See the class description for the special cases of this parameter.

startTime - The daylight saving time starting time in the time mode
specified by startTimeMode.

startTimeMode - The mode of the start time specified by startTime.

endMonth - The daylight saving time ending month. Month is
a MONTH field
value (0-based. e.g., 9 for October).

endDay - The day of the month on which the daylight saving time ends.
See the class description for the special cases of this parameter.

endDayOfWeek - The daylight saving time ending day-of-week.
See the class description for the special cases of this parameter.

endTime - The daylight saving ending time in time time mode
specified by endTimeMode.

endTimeMode - The mode of the end time specified by endTime

dstSavings - The amount of time in milliseconds saved during
daylight saving time.

setEndRule

Enabled: Sets the daylight saving time end rule. For example, if daylight saving time
ends on the last Sunday in October at 2 am in wall clock time,
you can set the end rule by calling:
setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*60*60*1000);

Parameters:

endMonth - The daylight saving time ending month. Month is
a MONTH field
value (0-based. e.g., 9 for October).

endDay - The day of the month on which the daylight saving time ends.
See the class description for the special cases of this parameter.

endDayOfWeek - The daylight saving time ending day-of-week.
See the class description for the special cases of this parameter.

endTime - The daylight saving ending time in local wall clock time,
(in milliseconds within the day) which is local daylight
time in this case.

setEndRule

public void setEndRule(int endMonth,
int endDay,
int endTime)

Enabled: Sets the daylight saving time end rule to a fixed date within a month.
This method is equivalent to:

setEndRule(endMonth, endDay, 0, endTime)

Parameters:

endMonth - The daylight saving time ending month. Month is
a MONTH field
value (0-based. e.g., 9 for October).

endDay - The day of the month on which the daylight saving time ends.

endTime - The daylight saving ending time in local wall clock time,
(in milliseconds within the day) which is local daylight
time in this case.

getOffset

Enabled: Returns the difference in milliseconds between local time and
UTC, taking into account both the raw offset and the effect of
daylight saving, for the specified date and time. This method
assumes that the start and end month are distinct. It also
uses a default GregorianCalendar object as its
underlying calendar, such as for determining leap years. Do
not use the result of this method with a calendar other than a
default GregorianCalendar.

Note: In general, clients should use
Calendar.get(ZONE_OFFSET) + Calendar.get(DST_OFFSET)
instead of calling this method.

getOffset

Gets offset, for current date, modified in case of
daylight saving time. This is the offset to add to UTC to get local time.
Gets the time zone offset, for current date, modified in case of daylight
saving time. This is the offset to add to UTC to get local time. Assume
that the start and end month are distinct.

Parameters:

era - The era of the given date.

year - The year in the given date.

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

Compares the given date in the year to the given rule and returns 1, 0,
or -1, depending on whether the date is after, equal to, or before the
rule date. The millis are compared directly against the ruleMillis, so
any standard-daylight adjustments must be handled by the caller.

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.

toString

decodeRules

private void decodeRules()

Given a set of encoded rules in startDay and startDayOfMonth, decode
them and set the startMode appropriately. Do the same for endDay and
endDayOfMonth. Upon entry, the day of week variables may be zero or
negative, in order to indicate special modes. The day of month
variables may also be negative. Upon exit, the mode variables will be
set, and the day of week and day of month variables will be positive.
This method also recognizes a startDay or endDay of zero as indicating
no DST.

decodeStartRule

private void decodeStartRule()

Decode the start rule and validate the parameters. The parameters are
expected to be in encoded form, which represents the various rule modes
by negating or zeroing certain values. Representation formats are:

The range for month does not include UNDECIMBER since this class is
really specific to GregorianCalendar, which does not use that month.
The range for time includes ONEDAY (vs. ending at ONEDAY-1) because the
end rule is an exclusive limit point. That is, the range of times that
are in DST include those >= the start and < the end. For this reason,
it should be possible to specify an end of ONEDAY in order to include the
entire day. Although this is equivalent to time 0 of the following day,
it's not always possible to specify that, for example, on December 31.
While arguably the start range should still be 0..ONEDAY-1, we keep
the start and end ranges the same for consistency.

decodeEndRule

private void decodeEndRule()

Decode the end rule and validate the parameters. This method is exactly
analogous to decodeStartRule().

See Also:

decodeStartRule

makeRulesCompatible

private void makeRulesCompatible()

Make rules compatible to 1.1 FCS code. Since 1.1 FCS code only understands
day-of-week-in-month rules, we must modify other modes of rules to their
approximate equivalent in 1.1 FCS terms. This method is used when streaming
out objects of this class. After it is called, the rules will be modified,
with a possible loss of information. startMode and endMode will NOT be
altered, even though semantically they should be set to DOW_IN_MONTH_MODE,
since the rule modification is only intended to be temporary.

packRules

private byte[] packRules()

Pack the start and end rules into an array of bytes. Only pack
data which is not preserved by makeRulesCompatible.

unpackRules

private void unpackRules(byte[] rules)

Given an array of bytes produced by packRules, interpret them
as the start and end rules.

packTimes

private int[] packTimes()

Pack the start and end times into an array of bytes. This is required
as of serial version 2.

unpackTimes

private void unpackTimes(int[] times)

Unpack the start and end times from an array of bytes. This is required
as of serial version 2.