java.util
Class SimpleTimeZone

java.lang.Object
  |
  +--java.util.TimeZone
        |
        +--java.util.SimpleTimeZone

public class SimpleTimeZone
extends TimeZone

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, Daylight Savings Time ends at the last (dayOfWeekInMonth = -1) Sunday in October, at 2 AM in standard time.

See Also:
Calendar, GregorianCalendar, TimeZone, Serialized Form

Field Summary
(package private) static int currentSerialVersion
           
private static int DOM_MODE
          Constants specifying values of startMode and endMode.
private static int DOW_GE_DOM_MODE
           
private static int DOW_IN_MONTH_MODE
           
private static int DOW_LE_DOM_MODE
           
private  int 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_MONTH endDay indicates the day of the month of endMonth on which daylight savings time ends, from 1 to 28, 30, or 31, depending on the endMonth.
private  int endDayOfWeek
          The day of the week on which daylight savings time ends.
private  int endMode
          Variables specifying the mode of the end rule.
private  int endMonth
          The month in which daylight savings time ends.
private  int endTime
          The time in milliseconds after midnight at which daylight savings time ends.
private static int millisPerDay
           
private static int millisPerHour
           
private  byte[] monthLength
          This field was serialized in JDK 1.1, so we have to keep it that way to maintain serialization compatibility.
private  int rawOffset
          The offset in milliseconds between this zone and GMT.
private  int serialVersionOnStream
          The version of the serialized data on the stream.
(package private) static long serialVersionUID
           
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 savings time starts, from 1 to 28, 30, or 31, depending on the startMonth.
private  int startDayOfWeek
          The day of the week on which daylight savings time starts.
private  int startMode
          Variables specifying the mode of the start rule.
private  int startMonth
          The month in which daylight savings time starts.
private  int startTime
          The time in milliseconds after midnight at which daylight savings time starts.
private  int startYear
          The year in which daylight savings time is first observed.
private static byte[] staticMonthLength
           
private  boolean useDaylight
          A boolean value which is true if and only if this zone uses daylight savings time.
 
Fields inherited from class java.util.TimeZone
cachedLocaleData, CUSTOM_ID, defaultZone, GMT, GMT_ID, GMT_ID_LENGTH, ID, LONG, numberFormat, ONE_DAY, ONE_HOUR, ONE_MINUTE, serialVersionUID, SHORT
 
Constructor Summary
SimpleTimeZone(int rawOffset, String ID)
          Constructs a SimpleTimeZone with the given base time zone offset from GMT and time zone ID.
SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime)
          Construct a SimpleTimeZone with the given base time zone offset from GMT, time zone ID, time to start and end the daylight time.
SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime, int dstSavings)
          Constructor.
 
Method Summary
 Object clone()
          Overrides Cloneable
private static int compareToRule(int month, int monthLen, int dayOfMonth, int dayOfWeek, int millis, int ruleMode, int ruleMonth, int ruleDayOfWeek, int ruleDay, int ruleMillis)
          Compare a given date in the year to a rule.
private  void decodeEndRule()
          Decode the end rule and validate the parameters.
private  void decodeRules()
          Given a set of encoded rules in startDay and startDayOfMonth, decode them and set the startMode appropriately.
private  void decodeStartRule()
          Decode the start rule and validate the parameters.
 boolean equals(Object obj)
          Compares the equality of two SimpleTimeZone objects.
 int getDSTSavings()
          Returns the amount of time in ms that the clock is advanced during DST.
 int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)
          Overrides TimeZone Gets offset, for current date, modified in case of daylight savings.
(package private)  int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis, int monthLength)
          Gets offset, for current date, modified in case of daylight savings.
 int getRawOffset()
          Overrides TimeZone Gets the GMT offset for this time zone.
 int hashCode()
          Override hashCode.
 boolean hasSameRules(TimeZone other)
          Return true if this zone has the same rules and offset as another zone.
 boolean inDaylightTime(Date date)
          Overrides TimeZone Queries if the given date is in Daylight Savings Time.
private  void makeRulesCompatible()
          Make rules compatible to 1.1 FCS code.
private  byte[] packRules()
          Pack the start and end rules into an array of bytes.
private  void readObject(ObjectInputStream stream)
          Reconstitute this object from a stream (i.e., deserialize it).
 void setDSTSavings(int millisSavedDuringDST)
          Sets the amount of time in ms that the clock is advanced during DST.
 void setEndRule(int month, int dayOfMonth, int time)
          Sets the DST end rule to a fixed date within a month.
 void setEndRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time)
          Sets the daylight savings ending rule.
 void setEndRule(int month, int dayOfMonth, int dayOfWeek, int time, boolean 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.
 void setRawOffset(int offsetMillis)
          Overrides TimeZone Sets the base time zone offset to GMT.
 void setStartRule(int month, int dayOfMonth, int time)
          Sets the DST start rule to a fixed date within a month.
 void setStartRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time)
          Sets the daylight savings starting rule.
 void setStartRule(int month, int dayOfMonth, int dayOfWeek, int time, boolean 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.
 void setStartYear(int year)
          Sets the daylight savings starting year.
 String toString()
          Return a string representation of this time zone.
private  void unpackRules(byte[] rules)
          Given an array of bytes produced by packRules, interpret them as the start and end rules.
 boolean useDaylightTime()
          Overrides TimeZone Queries if this time zone uses Daylight Savings Time.
private  void writeObject(ObjectOutputStream stream)
          Save the state of this object to a stream (i.e., serialize it).
 
Methods inherited from class java.util.TimeZone
getAvailableIDs, getAvailableIDs, getDefault, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getID, getTimeZone, parseCustomTimeZone, setDefault, setID
 
Methods inherited from class java.lang.Object
, finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

startMonth

private int startMonth
The month in which daylight savings 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 savings 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 savings 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 savings 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 savings time starts. This value is expressed as wall time, which means it is compared to standard time for the daylight savings start.

If useDaylight is false, this value is ignored.


endMonth

private int endMonth
The month in which daylight savings 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 savings 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 savings 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 savings 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 savings time ends. This value is expressed as wall time, which means it is compared to daylight time for the daylight savings end.

If useDaylight is false, this value is ignored.


startYear

private int startYear
The year in which daylight savings time is first observed. This is an AD value. If this value is less than 1 then daylight savings 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 savings 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

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:
JDK1.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:
JDK1.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:
JDK1.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

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.
When streaming out this class, the most recent format and the highest allowable serialVersionOnStream is written.
Since:
JDK1.1.4
Constructor Detail

SimpleTimeZone

public SimpleTimeZone(int rawOffset,
                      String 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. Normally you should use TimeZone.getDefault to construct a TimeZone.
Parameters:
rawOffset - The given base time zone offset to GMT.
ID - The time zone ID which is obtained from TimeZone.getAvailableIDs.

SimpleTimeZone

public SimpleTimeZone(int rawOffset,
                      String ID,
                      int startMonth,
                      int startDay,
                      int startDayOfWeek,
                      int startTime,
                      int endMonth,
                      int endDay,
                      int endDayOfWeek,
                      int endTime)
Construct a SimpleTimeZone with the given base time zone offset from GMT, time zone ID, time to start and end the daylight time. Timezone IDs can be obtained from TimeZone.getAvailableIDs. Normally you should use TimeZone.getDefault to create a TimeZone. For a time zone that does not use daylight saving time, do not use this constructor; instead you should use SimpleTimeZone(rawOffset, ID). By default, this constructor specifies day-of-week-in-month rules. That is, if the startDay is 1, and the startDayOfWeek is SUNDAY, then this indicates the first Sunday in the startMonth. A startDay of -1 likewise indicates the last Sunday. However, by using negative or zero values for certain parameters, other types of rules can be specified. Day of month. To specify an exact day of the month, such as March 1, set startDayOfWeek to zero. Day of week after day of month. To specify the first day of the week occurring on or after an exact day of the month, make the day of the week negative. For example, if startDay is 5 and startDayOfWeek is -MONDAY, this indicates the first Monday on or after the 5th day of the startMonth. Day of week before day of month. To specify the last day of the week occurring on or before an exact day of the month, make the day of the week and the day of the month negative. For example, if startDay is -21 and startDayOfWeek is -WEDNESDAY, this indicates the last Wednesday on or before the 21st of the startMonth. The above examples refer to the startMonth, startDay, and startDayOfWeek; the same applies for the endMonth, endDay, and endDayOfWeek.
Parameters:
rawOffset - The given base time zone offset to GMT.
ID - The time zone ID which is obtained from TimeZone.getAvailableIDs.
startMonth - The daylight savings starting month. Month is 0-based. eg, 0 for January.
startDay - The daylight savings starting day-of-week-in-month. Please see the member description for an example.
startDayOfWeek - The daylight savings starting day-of-week. Please see the member description for an example.
startTime - The daylight savings starting time in local wall time, which is standard time in this case. Please see the member description for an example.
endMonth - The daylight savings ending month. Month is 0-based. eg, 0 for January.
endDay - The daylight savings ending day-of-week-in-month. Please see the member description for an example.
endDayOfWeek - The daylight savings ending day-of-week. Please see the member description for an example.
endTime - The daylight savings ending time in local wall time, which is daylight time in this case. Please see the member description for an example.
Throws:
IllegalArgumentException - the month, day, dayOfWeek, or time parameters are out of range for the start or end rule

SimpleTimeZone

public SimpleTimeZone(int rawOffset,
                      String ID,
                      int startMonth,
                      int startDay,
                      int startDayOfWeek,
                      int startTime,
                      int endMonth,
                      int endDay,
                      int endDayOfWeek,
                      int endTime,
                      int dstSavings)
Constructor. This constructor is identical to the 10-argument constructor, but also takes a dstSavings parameter.
Parameters:
dstSavings - The amount of time in ms saved during DST.
Throws:
IllegalArgumentException - the month, day, dayOfWeek, or time parameters are out of range for the start or end rule
Method Detail

setStartYear

public void setStartYear(int year)
Sets the daylight savings starting year.
Parameters:
year - The daylight savings starting year.

setStartRule

public void setStartRule(int month,
                         int dayOfWeekInMonth,
                         int dayOfWeek,
                         int time)
Sets the daylight savings starting rule. For example, Daylight Savings Time starts at the first Sunday in April, at 2 AM in standard time. Therefore, you can set the start rule by calling: setStartRule(TimeFields.APRIL, 1, TimeFields.SUNDAY, 2*60*60*1000);
Parameters:
month - The daylight savings starting month. Month is 0-based. eg, 0 for January.
dayOfWeekInMonth - The daylight savings starting day-of-week-in-month. Please see the member description for an example.
dayOfWeek - The daylight savings starting day-of-week. Please see the member description for an example.
time - The daylight savings starting time in local wall time, which is standard time in this case. Please see the member description for an example.
Throws:
IllegalArgumentException - the month, dayOfWeekInMonth, dayOfWeek, or time parameters are out of range

setStartRule

public void setStartRule(int month,
                         int dayOfMonth,
                         int time)
Sets the DST start rule to a fixed date within a month.
Parameters:
month - The month in which this rule occurs (0-based).
dayOfMonth - The date in that month (1-based).
time - 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.
Throws:
IllegalArgumentException - the month, dayOfMonth, or time parameters are out of range

setStartRule

public void setStartRule(int month,
                         int dayOfMonth,
                         int dayOfWeek,
                         int time,
                         boolean 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.
Parameters:
month - The month in which this rule occurs (0-based).
dayOfMonth - A date within that month (1-based).
dayOfWeek - The day of the week on which this rule occurs.
time - 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.
after - If true, this rule selects the first dayOfWeek on or after dayOfMonth. If false, this rule selects the last dayOfWeek on or before dayOfMonth.
Throws:
IllegalArgumentException - the month, dayOfMonth, dayOfWeek, or time parameters are out of range

setEndRule

public void setEndRule(int month,
                       int dayOfWeekInMonth,
                       int dayOfWeek,
                       int time)
Sets the daylight savings ending rule. For example, Daylight Savings Time ends at the last (-1) Sunday in October, at 2 AM in standard time. Therefore, you can set the end rule by calling: setEndRule(TimeFields.OCTOBER, -1, TimeFields.SUNDAY, 2*60*60*1000);
Parameters:
month - The daylight savings ending month. Month is 0-based. eg, 0 for January.
dayOfWeekInMonth - The daylight savings ending day-of-week-in-month. Please see the member description for an example.
dayOfWeek - The daylight savings ending day-of-week. Please see the member description for an example.
time - The daylight savings ending time in local wall time, which is daylight time in this case. Please see the member description for an example.
Throws:
IllegalArgumentException - the month, dayOfWeekInMonth, dayOfWeek, or time parameters are out of range

setEndRule

public void setEndRule(int month,
                       int dayOfMonth,
                       int time)
Sets the DST end rule to a fixed date within a month.
Parameters:
month - The month in which this rule occurs (0-based).
dayOfMonth - The date in that month (1-based).
time - The time of that day (number of millis after midnight) when DST ends in local wall time, which is daylight time in this case.
Throws:
IllegalArgumentException - the month, dayOfMonth, or time parameters are out of range

setEndRule

public void setEndRule(int month,
                       int dayOfMonth,
                       int dayOfWeek,
                       int time,
                       boolean 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.
Parameters:
month - The month in which this rule occurs (0-based).
dayOfMonth - A date within that month (1-based).
dayOfWeek - The day of the week on which this rule occurs.
time - The time of that day (number of millis after midnight) when DST ends in local wall time, which is daylight time in this case.
after - If true, this rule selects the first dayOfWeek on or after dayOfMonth. If false, this rule selects the last dayOfWeek on or before dayOfMonth.
Throws:
IllegalArgumentException - the month, dayOfMonth, dayOfWeek, or time parameters are out of range

getOffset

public int getOffset(int era,
                     int year,
                     int month,
                     int day,
                     int dayOfWeek,
                     int millis)
Overrides TimeZone Gets offset, for current date, modified in case of daylight savings. 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 savings. This is the offset to add *to* UTC to get local time. Assume that the start and end month are distinct. This method may return incorrect results for rules that start at the end of February (e.g., last Sunday in February) or the beginning of March (e.g., March 1). To avoid such inaccuracies, use Calendar.get(ZONE_OFFSET) + Calendar.get(DST_OFFSET) instead.
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.
day - The day-in-month of the given date.
dayOfWeek - The day-of-week of the given date.
millis - The milliseconds in day in standard local time.
Returns:
The offset to add *to* GMT to get local time.
Throws:
IllegalArgumentException - the era, month, day, dayOfWeek, or millis parameters are out of range
Overrides:
getOffset in class TimeZone

getOffset

int getOffset(int era,
              int year,
              int month,
              int day,
              int dayOfWeek,
              int millis,
              int monthLength)
Gets offset, for current date, modified in case of daylight savings. 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 savings. 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.
day - The day-in-month of the given date.
dayOfWeek - The day-of-week of the given date.
millis - The milliseconds in day in standard local time.
monthLength - The length of the given month in days.
Returns:
The offset to add *to* GMT to get local time.
Throws:
IllegalArgumentException - the era, month, day, dayOfWeek, millis, or monthLength parameters are out of range
Overrides:
getOffset in class TimeZone

compareToRule

private static int compareToRule(int month,
                                 int monthLen,
                                 int dayOfMonth,
                                 int dayOfWeek,
                                 int millis,
                                 int ruleMode,
                                 int ruleMonth,
                                 int ruleDayOfWeek,
                                 int ruleDay,
                                 int ruleMillis)
Compare a given date in the year to a rule. Return 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.

getRawOffset

public int getRawOffset()
Overrides TimeZone Gets the GMT offset for this time zone.
Overrides:
getRawOffset in class TimeZone

setRawOffset

public void setRawOffset(int offsetMillis)
Overrides TimeZone Sets the base time zone offset to GMT. This is the offset to add *to* UTC to get local time. Please see TimeZone.setRawOffset for descriptions on the parameter.
Overrides:
setRawOffset in class TimeZone

setDSTSavings

public void setDSTSavings(int millisSavedDuringDST)
Sets the amount of time in ms that the clock is advanced during DST.
Parameters:
millisSavedDuringDST - the number of milliseconds the time is advanced with respect to standard time when the daylight savings rules are in effect. A positive number, typically one hour (3600000).

getDSTSavings

public int getDSTSavings()
Returns the amount of time in ms that the clock is advanced during DST.
Returns:
the number of milliseconds the time is advanced with respect to standard time when the daylight savings rules are in effect. A positive number, typically one hour (3600000).

useDaylightTime

public boolean useDaylightTime()
Overrides TimeZone Queries if this time zone uses Daylight Savings Time.
Overrides:
useDaylightTime in class TimeZone

inDaylightTime

public boolean inDaylightTime(Date date)
Overrides TimeZone Queries if the given date is in Daylight Savings Time.
Overrides:
inDaylightTime in class TimeZone

clone

public Object clone()
Overrides Cloneable
Overrides:
clone in class TimeZone

hashCode

public int hashCode()
Override hashCode. Generates the hash code for the SimpleDateFormat object
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Compares the equality of two SimpleTimeZone objects.
Parameters:
obj - The SimpleTimeZone object to be compared with.
Returns:
True if the given obj is the same as this SimpleTimeZone object; false otherwise.
Overrides:
equals in class Object

hasSameRules

public boolean hasSameRules(TimeZone other)
Return true if this zone has the same rules and offset as another zone.
Parameters:
other - the TimeZone object to be compared with
Returns:
true if the given zone has the same rules and offset as this one
Overrides:
hasSameRules in class TimeZone

toString

public String toString()
Return a string representation of this time zone.
Returns:
a string representation of this time zone.
Overrides:
toString in class Object

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:

            DOW_IN_MONTH  DOM    DOW>=DOM  DOW<=DOM  no DST
            ------------  -----  --------  --------  ----------
 month       0..11        same    same      same     don't care
 day        -5..5         1..31   1..31    -1..-31   0
 dayOfWeek   1..7         0      -1..-7    -1..-7    don't care
 time        0..ONEDAY    same    same      same     don't care
 
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.

writeObject

private void writeObject(ObjectOutputStream stream)
                  throws IOException
Save the state of this object to a stream (i.e., serialize it).

readObject

private void readObject(ObjectInputStream stream)
                 throws IOException,
                        ClassNotFoundException
Reconstitute this object from a stream (i.e., deserialize it). We handle both JDK 1.1 binary formats and full formats with a packed byte array.