|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.ibm.icu.util.TimeZone com.ibm.icu.util.BasicTimeZone com.ibm.icu.util.SimpleTimeZone
public class SimpleTimeZone
[icu enhancement] ICU's replacement for java.util.SimpleTimeZone
. 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.
Calendar
,
GregorianCalendar
,
TimeZone
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class com.ibm.icu.util.TimeZone |
---|
TimeZone.SystemTimeZoneType |
Field Summary | |
---|---|
static int |
STANDARD_TIME
Constant for a mode of start or end time specified as local standard time. |
static int |
UTC_TIME
Constant for a mode of start or end time specified as UTC. |
static int |
WALL_TIME
Constant for a mode of start or end time specified as local wall time. |
Fields inherited from class com.ibm.icu.util.BasicTimeZone |
---|
FORMER_LATTER_MASK, LOCAL_DST, LOCAL_FORMER, LOCAL_LATTER, LOCAL_STD, STD_DST_MASK |
Fields inherited from class com.ibm.icu.util.TimeZone |
---|
GENERIC_LOCATION, LONG, LONG_GENERIC, LONG_GMT, SHORT, SHORT_COMMONLY_USED, SHORT_GENERIC, SHORT_GMT, TIMEZONE_ICU, TIMEZONE_JDK, TimeZoneLogger, UNKNOWN_ZONE_ID |
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)
Constructs 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. |
|
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)
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. |
Method Summary | |
---|---|
Object |
clone()
Overrides clone. |
boolean |
equals(Object obj)
Overrides equals. |
int |
getDSTSavings()
Returns the amount of time in ms that the clock is advanced during DST. |
TimeZoneTransition |
getNextTransition(long base,
boolean inclusive)
[icu] Returns the first time zone transition after the base time. |
int |
getOffset(int era,
int year,
int month,
int day,
int dayOfWeek,
int millis)
Gets the time zone offset, for current date, modified in case of daylight savings. |
int |
getOffset(int era,
int year,
int month,
int day,
int dayOfWeek,
int millis,
int monthLength)
Deprecated. This API is ICU internal only. |
void |
getOffsetFromLocal(long date,
int nonExistingTimeOpt,
int duplicatedTimeOpt,
int[] offsets)
Deprecated. This API is ICU internal only. |
TimeZoneTransition |
getPreviousTransition(long base,
boolean inclusive)
[icu] Returns the last time zone transition before the base time. |
int |
getRawOffset()
Overrides TimeZone Gets the GMT offset for this time zone. |
TimeZoneRule[] |
getTimeZoneRules()
[icu] Returns the array of TimeZoneRule which represents the rule
of this time zone object. |
int |
hashCode()
Overrides hashCode. |
boolean |
hasSameRules(TimeZone othr)
Returns true if this zone has the same rules and offset as another zone. |
boolean |
inDaylightTime(Date date)
Overrides TimeZone Queries if the give date is in Daylight Saving Time. |
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 |
setID(String ID)
Sets the time zone ID. |
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()
Returns a string representation of this object. |
boolean |
useDaylightTime()
Overrides TimeZone Queries if this time zone uses Daylight Saving Time. |
Methods inherited from class com.ibm.icu.util.BasicTimeZone |
---|
getSimpleTimeZoneRulesNear, getTimeZoneRules, hasEquivalentTransitions, hasEquivalentTransitions |
Methods inherited from class com.ibm.icu.util.TimeZone |
---|
countEquivalentIDs, getAvailableIDs, getAvailableIDs, getAvailableIDs, getAvailableIDs, getCanonicalID, getCanonicalID, getDefault, getDefaultTimeZoneType, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getEquivalentID, getID, getOffset, getOffset, getRegion, getTimeZone, getTimeZone, getTZDataVersion, setDefault, setDefaultTimeZoneType |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int WALL_TIME
public static final int STANDARD_TIME
public static final int UTC_TIME
Constructor Detail |
---|
public SimpleTimeZone(int rawOffset, String ID)
rawOffset
- The given base time zone offset to GMT.ID
- The time zone ID which is obtained from
TimeZone.getAvailableIDs.public SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime)
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.
IllegalArgumentException
- the month, day, dayOfWeek, or time
parameters are out of range for the start or end rulepublic 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)
WALL_TIME
or STANDARD_TIME
or UTC_TIME
.
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.startTimeMode
- The mode of the start time specified by startTime.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.endTimeMode
- The mode of the end time specified by endTime.dstSavings
- The amount of time in ms saved during DST.
IllegalArgumentException
- the month, day, dayOfWeek, or time
parameters are out of range for the start or end rulepublic SimpleTimeZone(int rawOffset, String ID, int startMonth, int startDay, int startDayOfWeek, int startTime, int endMonth, int endDay, int endDayOfWeek, int endTime, int dstSavings)
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.dstSavings
- The amount of time in ms saved during DST.
IllegalArgumentException
- the month, day, dayOfWeek, or time
parameters are out of range for the start or end ruleMethod Detail |
---|
public void setID(String ID)
setID
in class TimeZone
ID
- the new time zone ID.public void setRawOffset(int offsetMillis)
setRawOffset
in class TimeZone
offsetMillis
- the raw offset of the time zonepublic int getRawOffset()
getRawOffset
in class TimeZone
public void setStartYear(int year)
year
- The daylight savings starting year.public void setStartRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time)
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.
IllegalArgumentException
- the month, dayOfWeekInMonth,
dayOfWeek, or time parameters are out of rangepublic void setStartRule(int month, int dayOfMonth, int time)
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.
IllegalArgumentException
- the month,
dayOfMonth, or time parameters are out of rangepublic void setStartRule(int month, int dayOfMonth, int dayOfWeek, int time, boolean after)
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.
IllegalArgumentException
- the month, dayOfMonth,
dayOfWeek, or time parameters are out of rangepublic void setEndRule(int month, int dayOfWeekInMonth, int dayOfWeek, int time)
setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2*60*60*1000);
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.
IllegalArgumentException
- the month, dayOfWeekInMonth,
dayOfWeek, or time parameters are out of rangepublic void setEndRule(int month, int dayOfMonth, int time)
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.
IllegalArgumentException
- the month,
dayOfMonth, or time parameters are out of rangepublic void setEndRule(int month, int dayOfMonth, int dayOfWeek, int time, boolean after)
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.
IllegalArgumentException
- the month, dayOfMonth,
dayOfWeek, or time parameters are out of rangepublic void setDSTSavings(int millisSavedDuringDST)
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).public int getDSTSavings()
getDSTSavings
in class TimeZone
public String toString()
toString
in class Object
public int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis)
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 millis in day in standard local time.
public int getOffset(int era, int year, int month, int day, int dayOfWeek, int millis, int monthLength)
public void getOffsetFromLocal(long date, int nonExistingTimeOpt, int duplicatedTimeOpt, int[] offsets)
getOffsetFromLocal
in class BasicTimeZone
public boolean useDaylightTime()
useDaylightTime
in class TimeZone
Note:The default implementation of
ICU TimeZone uses the tz database, which supports historic
rule changes, for system time zones. With the implementation,
there are time zones that used daylight savings time in the
past, but no longer used currently. For example, Asia/Tokyo has
never used daylight savings time since 1951. Most clients would
expect that this method to return false
for such case.
The default implementation of this method returns true
when the time zone uses daylight savings time in the current
(Gregorian) calendar year.
public boolean inDaylightTime(Date date)
inDaylightTime
in class TimeZone
date
- the given Date.
public boolean equals(Object obj)
equals
in class TimeZone
public int hashCode()
hashCode
in class TimeZone
public Object clone()
clone
in class TimeZone
public boolean hasSameRules(TimeZone othr)
hasSameRules
in class TimeZone
othr
- the TimeZone object to be compared with
public TimeZoneTransition getNextTransition(long base, boolean inclusive)
getNextTransition
in class BasicTimeZone
base
- The base time.inclusive
- Whether the base time is inclusive or not.
Date
holding the first time zone transition time
after the given base time, or null if no time zone transitions
are available after the base time.public TimeZoneTransition getPreviousTransition(long base, boolean inclusive)
getPreviousTransition
in class BasicTimeZone
base
- The base time.inclusive
- Whether the base time is inclusive or not.
Date
holding the last time zone transition time
before the given base time, or null if no time zone transitions
are available before the base time.public TimeZoneRule[] getTimeZoneRules()
TimeZoneRule
which represents the rule
of this time zone object. The first element in the result array will
be the InitialTimeZoneRule
instance for the initial rule.
The rest will be either AnnualTimeZoneRule
or
TimeArrayTimeZoneRule
instances representing transitions.
getTimeZoneRules
in class BasicTimeZone
TimeZoneRule
which represents this
time zone.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |