|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.TimeZone | +--java.util.SimpleTimeZone
Untamed:
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
saving time ends, from 1 to 28, 30, or 31, depending on the
endMonth . |
private int |
endDayOfWeek
The day of the week on which daylight saving time ends. |
private int |
endMode
Variables specifying the mode of the end rule. |
private int |
endMonth
The month in which daylight saving time ends. |
private int |
endTime
The time in milliseconds after midnight at which daylight saving time ends. |
private int |
endTimeMode
The format of endTime, either WALL_TIME, STANDARD_TIME, or UTC_TIME. |
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
|
static int |
STANDARD_TIME
Enabled: 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_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 . |
private int |
startDayOfWeek
The day of the week on which daylight saving time starts. |
private int |
startMode
Variables specifying the mode of the start rule. |
private int |
startMonth
The month in which daylight saving time starts. |
private int |
startTime
The time in milliseconds after midnight at which daylight saving time starts. |
private int |
startTimeMode
The format of startTime, either WALL_TIME, STANDARD_TIME, or UTC_TIME. |
private int |
startYear
The year in which daylight saving time is first observed. |
private static byte[] |
staticLeapMonthLength
|
private static byte[] |
staticMonthLength
|
private boolean |
useDaylight
A boolean value which is true if and only if this zone uses daylight saving time. |
static int |
UTC_TIME
Enabled: Constant for a mode of start or end time specified as UTC. |
static int |
WALL_TIME
Enabled: Constant for a mode of start or end time specified as wall clock time. |
Fields inherited from class java.util.TimeZone |
GMT_ID, LONG, SHORT |
Constructor Summary | |
SimpleTimeZone(int rawOffset,
String ID)
Enabled: Constructs a SimpleTimeZone with the given base time zone offset from GMT and time zone ID with no daylight saving time schedule. |
|
SimpleTimeZone(int rawOffset,
String ID,
int startMonth,
int startDay,
int startDayOfWeek,
int startTime,
int endMonth,
int endDay,
int endDayOfWeek,
int endTime)
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. |
|
SimpleTimeZone(int rawOffset,
String ID,
int startMonth,
int startDay,
int startDayOfWeek,
int startTime,
int endMonth,
int endDay,
int endDayOfWeek,
int endTime,
int dstSavings)
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. |
|
SimpleTimeZone(int rawOffset,
String ID,
int startMonth,
int startDay,
int startDayOfWeek,
int startTime,
int startTimeMode,
int endMonth,
int endDay,
int endDayOfWeek,
int endTime,
int endTimeMode,
int dstSavings)
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. |
Method Summary | |
Object |
clone()
Suppressed: Returns a clone of this SimpleTimeZone instance. |
private static int |
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)
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. |
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)
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. |
private int |
getOffset(int era,
int year,
int month,
int day,
int dayOfWeek,
int millis,
int monthLength,
int prevMonthLength)
Gets offset, for current date, modified in case of daylight saving time. |
int |
getOffset(long date)
Enabled: Returns the offset of this time zone from UTC at the given time. |
(package private) int |
getOffsets(long date,
int[] offsets)
Gets the raw GMT offset and the amount of daylight saving of this time zone at the given time. |
int |
getRawOffset()
Enabled: Gets the GMT offset for this time zone. |
int |
hashCode()
Suppressed: Generates the hash code for the SimpleDateFormat object. |
boolean |
hasSameRules(TimeZone other)
Enabled: Returns true if this zone has the same rules and offset as another zone. |
boolean |
inDaylightTime(Date date)
Enabled: Queries if the given date is in daylight saving 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 int[] |
packTimes()
Pack the start and end times into an array of bytes. |
private void |
readObject(ObjectInputStream stream)
Reconstitute this object from a stream (i.e., deserialize it). |
void |
setDSTSavings(int millisSavedDuringDST)
Enabled: Sets the amount of time in milliseconds that the clock is advanced during daylight saving time. |
void |
setEndRule(int endMonth,
int endDay,
int endTime)
Enabled: Sets the daylight saving time end rule to a fixed date within a month. |
void |
setEndRule(int endMonth,
int endDay,
int endDayOfWeek,
int endTime)
Enabled: Sets the daylight saving time end rule. |
void |
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. |
void |
setStartRule(int startMonth,
int startDay,
int startDayOfWeek,
int startTime)
Enabled: Sets the daylight saving time start rule. |
void |
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. |
void |
setStartYear(int year)
Enabled: Sets the daylight saving time starting year. |
String |
toString()
Suppressed: Returns 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. |
private void |
unpackTimes(int[] times)
Unpack the start and end times from an array of bytes. |
boolean |
useDaylightTime()
Enabled: Queries if this time zone uses daylight saving 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, setDefault, setID |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
private int startMonth
Calendar.JANUARY
and
Calendar.DECEMBER
inclusive. This value must not equal
endMonth
.
If useDaylight
is false, this value is ignored.
private int startDay
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.
private int startDayOfWeek
Calendar.SUNDAY
and
Calendar.SATURDAY
inclusive.
If useDaylight
is false or
startMode == DAY_OF_MONTH
, this value is ignored.
private int startTime
startTimeMode
.
If useDaylight
is false, this value is ignored.
private int startTimeMode
private int endMonth
Calendar.JANUARY
and
Calendar.UNDECIMBER
. This value must not equal
startMonth
.
If useDaylight
is false, this value is ignored.
private int endDay
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.
private int endDayOfWeek
Calendar.SUNDAY
and
Calendar.SATURDAY
inclusive.
If useDaylight
is false or
endMode == DAY_OF_MONTH
, this value is ignored.
private int endTime
endTimeMode
.
If useDaylight
is false, this value is ignored.
private int endTimeMode
private int startYear
If useDaylight
is false, this value is ignored.
private int rawOffset
dstSavings
.
private boolean useDaylight
private static final int millisPerHour
private static final int millisPerDay
private final byte[] monthLength
private static final byte[] staticMonthLength
private static final byte[] staticLeapMonthLength
private int startMode
DOM_MODE
DOW_IN_MONTH_MODE
DOW_GE_DOM_MODE
DOW_LE_DOM_MODE
startDay
field.
If useDaylight
is false, this value is ignored.
private int endMode
DOM_MODE
DOW_IN_MONTH_MODE
DOW_GE_DOM_MODE
DOW_LE_DOM_MODE
endDay
field.
If useDaylight
is false, this value is ignored.
private int dstSavings
If useDaylight
is false, this value is ignored.
private static final int DOM_MODE
private static final int DOW_IN_MONTH_MODE
private static final int DOW_GE_DOM_MODE
private static final int DOW_LE_DOM_MODE
public static final int WALL_TIME
public static final int STANDARD_TIME
public static final int UTC_TIME
static final long serialVersionUID
static final int currentSerialVersion
private int serialVersionOnStream
startMode
,
endMode
, and dstSavings
.
startTimeMode
and endTimeMode
.
serialVersionOnStream
is written.
Constructor Detail |
public SimpleTimeZone(int rawOffset, String ID)
rawOffset
- The base time zone offset in milliseconds to GMT.ID
- The time zone name that is given to this instance.public SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime)
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(rawOffset,
ID,
startMonth,
startDay,
startDayOfWeek,
startTime,
SimpleTimeZone.WALL_TIME
,
endMonth,
endDay,
endDayOfWeek,
endTime,
SimpleTimeZone.WALL_TIME
,
3600000)
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 local wall clock
time (in milliseconds within the day), which is local
standard time in this case.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.public SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime, int dstSavings)
startTime
and endTime
are assumed to be
represented in the wall clock time. This constructor is equivalent to:
SimpleTimeZone(rawOffset,
ID,
startMonth,
startDay,
startDayOfWeek,
startTime,
SimpleTimeZone.WALL_TIME
,
endMonth,
endDay,
endDayOfWeek,
endTime,
SimpleTimeZone.WALL_TIME
,
dstSavings)
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 local wall clock
time, which is local standard time in this case.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,
which is local daylight time in this case.dstSavings
- The amount of time in milliseconds saved during
daylight saving time.public SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDay, int startDayOfWeek, int startTime, int startTimeMode, int endMonth, int endDay, int endDayOfWeek, int endTime, int endTimeMode, int dstSavings)
startTime
and
endTime
. The mode specifies either wall
time
or standard time
or UTC
time
.
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 endTimedstSavings
- The amount of time in milliseconds saved during
daylight saving time.WALL_TIME
,
STANDARD_TIME
,
UTC_TIME
Method Detail |
public void setStartYear(int year)
year
- The daylight saving starting year.public void setStartRule(int startMonth, int startDay, int startDayOfWeek, int startTime)
setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2*60*60*1000);
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 local wall clock
time, which is local standard time in this case.public void setStartRule(int startMonth, int startDay, int startTime)
setStartRule(startMonth, startDay, 0, startTime)
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.startTime
- The daylight saving time starting time in local wall clock
time, which is local standard time in this case.
See the class description for the special cases of this parameter.public void setStartRule(int startMonth, int startDay, int startDayOfWeek, int startTime, boolean after)
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.startDayOfWeek
- The daylight saving time starting day-of-week.startTime
- The daylight saving time starting time in local wall clock
time, which is local 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
.public void setEndRule(int endMonth, int endDay, int endDayOfWeek, int endTime)
setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*60*60*1000);
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.public void setEndRule(int endMonth, int endDay, int endTime)
setEndRule(endMonth, endDay, 0, endTime)
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.public void setEndRule(int endMonth, int endDay, int endDayOfWeek, int endTime, boolean after)
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.endDayOfWeek
- The daylight saving time ending day-of-week.endTime
- The daylight saving ending time in local wall clock time,
(in milliseconds within the day) which is local daylight
time in this case.after
- If true, this rule selects the first endDayOfWeek
on
or after endDay
. If false, this rule
selects the last endDayOfWeek
on or before
endDay
of the month.public int getOffset(long date)
getOffset
in class TimeZone
date
- the time at which the time zone offset is found
Calendar.ZONE_OFFSET
,
Calendar.DST_OFFSET
int getOffsets(long date, int[] offsets)
TimeZone
getOffsets
in class TimeZone
date
- the milliseconds (since January 1, 1970,
00:00:00.000 GMT) at which the time zone offset and daylight
saving amount are found
TimeZone.getOffsets(long, int[])
public int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)
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
in class TimeZone
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.
Calendar.ZONE_OFFSET
,
Calendar.DST_OFFSET
private int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis, int monthLength, int prevMonthLength)
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.prevMonthLength
- The length of the previous month in days.
private static int 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)
public int getRawOffset()
getRawOffset
in class TimeZone
setRawOffset(int)
public void setRawOffset(int offsetMillis)
setRawOffset
in class TimeZone
offsetMillis
- the given base time zone offset to GMT.getRawOffset()
public void setDSTSavings(int millisSavedDuringDST)
millisSavedDuringDST
- the number of milliseconds the time is
advanced with respect to standard time when the daylight saving time rules
are in effect. A positive number, typically one hour (3600000).getDSTSavings()
public int getDSTSavings()
getDSTSavings
in class TimeZone
setDSTSavings(int)
public boolean useDaylightTime()
useDaylightTime
in class TimeZone
public boolean inDaylightTime(Date date)
inDaylightTime
in class TimeZone
date
- the given Date.
public Object clone()
SimpleTimeZone
instance.
clone
in class TimeZone
public int hashCode()
hashCode
in class Object
java.lang.Object#equals(java.lang.Object)
,
java.util.Hashtable
public boolean equals(Object obj)
SimpleTimeZone
objects.
equals
in class Object
obj
- The SimpleTimeZone
object to be compared with.
obj
is the same as this
SimpleTimeZone
object; false otherwise.Object.hashCode()
,
java.util.Hashtable
public boolean hasSameRules(TimeZone other)
hasSameRules
in class TimeZone
other
- the TimeZone object to be compared with
public String toString()
toString
in class Object
private void decodeRules()
private void decodeStartRule()
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 careThe 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.
private void decodeEndRule()
decodeStartRule
private void makeRulesCompatible()
private byte[] packRules()
private void unpackRules(byte[] rules)
private int[] packTimes()
private void unpackTimes(int[] times)
private void writeObject(ObjectOutputStream stream) throws IOException
IOException
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException
IOException
ClassNotFoundException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |