java.lang.Object | ||
↳ | java.util.TimeZone | |
↳ | java.util.SimpleTimeZone |
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.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | STANDARD_TIME | The constant for representing a start or end time in standard local time mode, based on timezone's raw offset from GMT; does not include Daylight savings. | |||||||||
int | UTC_TIME | The constant for representing a start or end time in GMT time mode. | |||||||||
int | WALL_TIME | The constant for representing a start or end time in local wall clock time mode, based on timezone's adjusted offset from GMT; includes Daylight savings. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.util.TimeZone
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a
SimpleTimeZone with the given base time zone offset from GMT
and time zone ID. | |||||||||||
Constructs a
SimpleTimeZone with the given base time zone offset from GMT,
time zone ID, and times to start and end the daylight savings time. | |||||||||||
Constructs a
SimpleTimeZone with the given base time zone offset from GMT,
time zone ID, times to start and end the daylight savings time, and
the daylight savings time difference in milliseconds. | |||||||||||
Construct a
SimpleTimeZone with the given base time zone offset from GMT,
time zone ID, times to start and end the daylight savings time including a
mode specifier, the daylight savings time difference in milliseconds. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a new
SimpleTimeZone with the same ID, rawOffset and daylight
savings time rules as this SimpleTimeZone. | |||||||||||
Compares the specified object to this
SimpleTimeZone and returns whether they
are equal. | |||||||||||
Gets the daylight savings offset in milliseconds for this
TimeZone . | |||||||||||
Gets the offset from GMT of this
TimeZone for the specified date and
time. | |||||||||||
Gets the offset from GMT of this
TimeZone for the specified date. | |||||||||||
Gets the offset for standard time from GMT for this
TimeZone . | |||||||||||
Returns whether the specified
TimeZone has the same raw offset as this
TimeZone . | |||||||||||
Returns an integer hash code for the receiver.
| |||||||||||
Returns whether the specified
Date is in the daylight savings time period for
this TimeZone . | |||||||||||
Sets the daylight savings offset in milliseconds for this
SimpleTimeZone . | |||||||||||
Sets the rule which specifies the end of daylight savings time.
| |||||||||||
Sets the rule which specifies the end of daylight savings time.
| |||||||||||
Sets the rule which specifies the end of daylight savings time.
| |||||||||||
Sets the offset for standard time from GMT for this
SimpleTimeZone . | |||||||||||
Sets the rule which specifies the start of daylight savings time.
| |||||||||||
Sets the rule which specifies the start of daylight savings time.
| |||||||||||
Sets the rule which specifies the start of daylight savings time.
| |||||||||||
Sets the starting year for daylight savings time in this
SimpleTimeZone . | |||||||||||
Returns the string representation of this
SimpleTimeZone . | |||||||||||
Returns whether this
TimeZone has a daylight savings time period. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.util.TimeZone
| |||||||||||
From class java.lang.Object
|
The constant for representing a start or end time in standard local time mode, based on timezone's raw offset from GMT; does not include Daylight savings.
The constant for representing a start or end time in GMT time mode.
The constant for representing a start or end time in local wall clock time mode, based on timezone's adjusted offset from GMT; includes Daylight savings.
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
.
offset | the given base time zone offset to GMT. |
---|---|
name | the time zone ID which is obtained from
TimeZone.getAvailableIDs .
|
Constructs a SimpleTimeZone
with the given base time zone offset from GMT,
time zone ID, and times to start and end the daylight savings 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
.
The daylight savings time difference is set to the default value: one hour.
offset | the given base time zone offset to GMT. |
---|---|
name | the time zone ID which is obtained from
TimeZone.getAvailableIDs . |
startMonth | the daylight savings starting month. The month indexing 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. The month indexing 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. |
IllegalArgumentException | if the month, day, dayOfWeek, or time parameters are out of range for the start or end rule. |
---|
Constructs a SimpleTimeZone
with the given base time zone offset from GMT,
time zone ID, times to start and end the daylight savings time, and
the daylight savings time difference in milliseconds.
offset | the given base time zone offset to GMT. |
---|---|
name | 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 description of SimpleTimeZone(int, String, int, int, int, int, int, int, int, int) for an example. |
startDayOfWeek | the daylight savings starting day-of-week. Please see the
description of SimpleTimeZone(int, String, int, int, int, int, int, int, int, int) for an example. |
startTime | The daylight savings starting time in local wall time, which
is standard time in this case. Please see the description of
SimpleTimeZone(int, String, int, int, int, int, int, int, int, int) 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 description of SimpleTimeZone(int, String, int, int, int, int, int, int, int, int) for an example. |
endDayOfWeek | the daylight savings ending day-of-week. Please see the description of
SimpleTimeZone(int, String, int, int, int, int, int, int, int, int) for an example. |
endTime | the daylight savings ending time in local wall time, which is
daylight time in this case. Please see the description of SimpleTimeZone(int, String, int, int, int, int, int, int, int, int)
for an example. |
daylightSavings | the daylight savings time difference in milliseconds. |
IllegalArgumentException | if the month, day, dayOfWeek, or time parameters are out of range for the start or end rule. |
---|
Construct a SimpleTimeZone
with the given base time zone offset from GMT,
time zone ID, times to start and end the daylight savings time including a
mode specifier, the daylight savings time difference in milliseconds.
The mode specifies either WALL_TIME
, STANDARD_TIME
, or
UTC_TIME
.
offset | the given base time zone offset to GMT. |
---|---|
name | the time zone ID which is obtained from
TimeZone.getAvailableIDs . |
startMonth | the daylight savings starting month. The month indexing is 0-based. eg, 0 for January. |
startDay | the daylight savings starting day-of-week-in-month. Please see
the description of SimpleTimeZone(int, String, int, int, int, int, int, int, int, int) for an example. |
startDayOfWeek | the daylight savings starting day-of-week. Please see the
description of SimpleTimeZone(int, String, int, int, int, int, int, int, int, int) for an example. |
startTime | the time of day in milliseconds on which daylight savings
time starts, based on the startTimeMode . |
startTimeMode | the mode (UTC, standard, or wall time) of the start time value. |
endMonth | the daylight savings ending month. The month indexing is 0-based. eg, 0 for January. |
endDay | the day of the week on which daylight savings time ends. |
endDayOfWeek | the daylight savings ending day-of-week. Please see the description of
SimpleTimeZone(int, String, int, int, int, int, int, int, int, int) for an example. |
endTime | the time of day in milliseconds on which daylight savings
time ends, based on the endTimeMode . |
endTimeMode | the mode (UTC, standard, or wall time) of the end time value. |
daylightSavings | the daylight savings time difference in milliseconds. |
IllegalArgumentException | if the month, day, dayOfWeek, or time parameters are out of range for the start or end rule. |
---|
Returns a new SimpleTimeZone
with the same ID, rawOffset
and daylight
savings time rules as this SimpleTimeZone.
SimpleTimeZone
.Compares the specified object to this SimpleTimeZone
and returns whether they
are equal. The object must be an instance of SimpleTimeZone
and have the
same internal data.
object | the object to compare with this object. |
---|
true
if the specified object is equal to this
SimpleTimeZone
, false
otherwise.Gets the daylight savings offset in milliseconds for this TimeZone
.
This implementation returns 3600000 (1 hour), or 0 if the time zone does not observe daylight savings.
Subclasses may override to return daylight savings values other than 1 hour.
TimeZone
observes daylight savings, zero otherwise.
Gets the offset from GMT of this TimeZone
for the specified date and
time. The offset includes daylight savings time if the specified date and
time are within the daylight savings time period.
era | the GregorianCalendar era, either GregorianCalendar.BC or
GregorianCalendar.AD . |
---|---|
year | the year. |
month | the Calendar month. |
day | the day of the month. |
dayOfWeek | the Calendar day of the week. |
time | the time of day in milliseconds. |
Gets the offset from GMT of this TimeZone
for the specified date. The
offset includes daylight savings time if the specified date is within the
daylight savings time period.
time | the date in milliseconds since January 1, 1970 00:00:00 GMT |
---|
Gets the offset for standard time from GMT for this TimeZone
.
Returns whether the specified TimeZone
has the same raw offset as this
TimeZone
.
zone | a TimeZone . |
---|
true
when the TimeZone
have the same raw offset, false
otherwise.
Returns an integer hash code for the receiver. Objects which are equal return the same value for this method.
Returns whether the specified Date
is in the daylight savings time period for
this TimeZone
.
time | a Date . |
---|
true
when the Date
is in the daylight savings time period, false
otherwise.
Sets the daylight savings offset in milliseconds for this SimpleTimeZone
.
milliseconds | the daylight savings offset in milliseconds. |
---|
Sets the rule which specifies the end of daylight savings time.
month | the Calendar month in which daylight savings time ends. |
---|---|
day | the occurrence of the day of the week on which daylight savings time ends. |
dayOfWeek | the Calendar day of the week on which daylight savings time
ends. |
time | the time of day in milliseconds standard time on which daylight savings time ends. |
Sets the rule which specifies the end of daylight savings time.
month | the Calendar month in which daylight savings time ends. |
---|---|
day | the Calendar day of the month. |
dayOfWeek | the Calendar day of the week on which daylight savings time
ends. |
time | the time of day in milliseconds on which daylight savings time ends. |
after | selects the day after or before the day of month. |
Sets the rule which specifies the end of daylight savings time.
month | the Calendar month in which daylight savings time ends. |
---|---|
dayOfMonth | the Calendar day of the month on which daylight savings time
ends. |
time | the time of day in milliseconds standard time on which daylight savings time ends. |
Sets the offset for standard time from GMT for this SimpleTimeZone
.
offset | the offset from GMT of standard time in milliseconds. |
---|
Sets the rule which specifies the start of daylight savings time.
month | the Calendar month in which daylight savings time starts. |
---|---|
dayOfMonth | the Calendar day of the month on which daylight savings time
starts. |
time | the time of day in milliseconds on which daylight savings time starts. |
Sets the rule which specifies the start of daylight savings time.
month | the Calendar month in which daylight savings time starts. |
---|---|
day | the occurrence of the day of the week on which daylight savings time starts. |
dayOfWeek | the Calendar day of the week on which daylight savings time
starts. |
time | the time of day in milliseconds on which daylight savings time starts. |
Sets the rule which specifies the start of daylight savings time.
month | the Calendar month in which daylight savings time starts. |
---|---|
day | the Calendar day of the month. |
dayOfWeek | the Calendar day of the week on which daylight savings time
starts. |
time | the time of day in milliseconds on which daylight savings time starts. |
after | selects the day after or before the day of month. |
Sets the starting year for daylight savings time in this SimpleTimeZone
.
Years before this start year will always be in standard time.
year | the starting year. |
---|
Returns the string representation of this SimpleTimeZone
.
SimpleTimeZone
.
Returns whether this TimeZone
has a daylight savings time period.
true
if this TimeZone
has a daylight savings time period, false
otherwise.