public class OlsonTimeZone extends BasicTimeZone
BasicTimeZone.LocalOptionTimeZone.SystemTimeZoneTypeGENERIC_LOCATION, GMT_ZONE, LONG, LONG_GENERIC, LONG_GMT, SHORT, SHORT_COMMONLY_USED, SHORT_GENERIC, SHORT_GMT, TIMEZONE_ICU, TIMEZONE_JDK, UNKNOWN_ZONE, UNKNOWN_ZONE_ID| Constructor and Description |
|---|
OlsonTimeZone(String id) |
OlsonTimeZone(UResourceBundle top,
UResourceBundle res,
String id)
Construct from a resource bundle
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Overrides clone.
|
TimeZone |
cloneAsThawed()
Provides for the clone operation.
|
boolean |
equals(Object obj)
Overrides equals.
|
TimeZone |
freeze()
Freezes the object.
|
String |
getCanonicalID()
Returns the canonical ID of this system time zone
|
int |
getDSTSavings()
TimeZone API
Returns the amount of time to be added to local standard time
to get local wall clock time.
|
TimeZoneTransition |
getNextTransition(long base,
boolean inclusive)
Returns the first time zone transition after the base time.
|
int |
getOffset(int era,
int year,
int month,
int day,
int dayOfWeek,
int milliseconds)
Gets the time zone offset, for current date, modified in case of
daylight savings.
|
int |
getOffset(int era,
int year,
int month,
int dom,
int dow,
int millis,
int monthLength)
TimeZone API.
|
void |
getOffset(long date,
boolean local,
int[] offsets)
TimeZone API.
|
void |
getOffsetFromLocal(long date,
BasicTimeZone.LocalOption nonExistingTimeOpt,
BasicTimeZone.LocalOption duplicatedTimeOpt,
int[] offsets)
Returns time zone offsets from local wall time.
|
TimeZoneTransition |
getPreviousTransition(long base,
boolean inclusive)
Returns the last time zone transition before the base time.
|
int |
getRawOffset()
Gets unmodified offset, NOT modified in case of daylight savings.
|
TimeZoneRule[] |
getTimeZoneRules()
Returns the array of
TimeZoneRule which represents the rule
of this time zone object. |
int |
hashCode()
Overrides hashCode.
|
boolean |
hasSameRules(TimeZone other)
Returns true if this zone has the same rule and offset as another zone.
|
boolean |
inDaylightTime(Date date)
Queries if the given date is in daylight savings time in
this time zone.
|
boolean |
isFrozen()
Determines whether the object has been frozen or not.
|
boolean |
observesDaylightTime()
Queries if this time zone is in daylight saving time or will observe
daylight saving time at any future time.
|
void |
setID(String id)
Sets the time zone ID.
|
void |
setRawOffset(int offsetMillis)
Sets the base time zone offset to GMT.
|
String |
toString() |
boolean |
useDaylightTime()
Queries if this time zone uses daylight savings time.
|
getSimpleTimeZoneRulesNear, getTimeZoneRules, hasEquivalentTransitions, hasEquivalentTransitionscountEquivalentIDs, getAvailableIDs, getAvailableIDs, getAvailableIDs, getAvailableIDs, getCanonicalID, getCanonicalID, getDefault, getDefaultTimeZoneType, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getDisplayName, getEquivalentID, getFrozenTimeZone, getID, getIDForWindowsID, getOffset, getRegion, getTimeZone, getTimeZone, getTZDataVersion, getWindowsID, setDefault, setDefaultTimeZoneTypepublic OlsonTimeZone(UResourceBundle top, UResourceBundle res, String id)
top - the top-level zoneinfo resource bundle. This is used
to lookup the rule that `res' may refer to, if there is one.res - the resource bundle of the zone to be constructedid - time zone IDpublic OlsonTimeZone(String id)
public int getOffset(int era,
int year,
int month,
int day,
int dayOfWeek,
int milliseconds)
TimeZonegetOffset in class TimeZoneera - 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.milliseconds - the millis in day in standard local time.public int getOffset(int era,
int year,
int month,
int dom,
int dow,
int millis,
int monthLength)
public void setRawOffset(int offsetMillis)
TimeZonesetRawOffset in class TimeZoneoffsetMillis - the given base time zone offset to GMT.public void getOffset(long date,
boolean local,
int[] offsets)
getOffset in class TimeZonedate - moment in time for which to return offsets, in
units of milliseconds from January 1, 1970 0:00 GMT, either GMT
time or local wall time, depending on `local'.local - if true, `date' is local wall time; otherwise it
is in GMT time.offsets - output parameter to receive the raw offset, that
is, the offset not including DST adjustments, in offsets[0],
and the DST offset, that is, the offset to be added to
`rawOffset' to obtain the total offset between local and GMT
time, in offsets[1]. If DST is not in effect, the DST offset is
zero; otherwise it is a positive value, typically one hour.public void getOffsetFromLocal(long date,
BasicTimeZone.LocalOption nonExistingTimeOpt,
BasicTimeZone.LocalOption duplicatedTimeOpt,
int[] offsets)
getOffsetFromLocal in class BasicTimeZonepublic int getRawOffset()
TimeZonegetRawOffset in class TimeZonepublic boolean useDaylightTime()
TimeZoneuseDaylightTime in class TimeZoneNote: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 observesDaylightTime()
TimeZoneThe default implementation in this class returns true if TimeZone.useDaylightTime()
or inDaylightTime(new Date()) returns true.
Note: This method was added for TimeZone compatibility
support. The TimeZone.useDaylightTime() method only checks the last known
rule(s), therefore it may return false even the zone observes daylight saving time currently.
TimeZone added observesDaylightTime() to resolve the issue.
In ICU, TimeZone.useDaylightTime() works differently. The ICU implementation checks if the
zone uses daylight saving time in the current calendar year. Therefore, it will never return
false if daylight saving time is currently used.
ICU's TimeZone subclass implementations override this method to support the same behavior
with TimeZone.observesDaylightTime(). Unlike TimeZone.useDaylightTime(),
the implementation does not take past daylight saving time into account, so
that this method may return false even when TimeZone.useDaylightTime() returns
true.
observesDaylightTime in class TimeZonetrue if this time zone is in daylight saving time or will observe
daylight saving time at any future time.TimeZone.useDaylightTime()public int getDSTSavings()
getDSTSavings in class TimeZonepublic boolean inDaylightTime(Date date)
TimeZoneinDaylightTime in class TimeZonedate - the given Date.public boolean hasSameRules(TimeZone other)
TimeZonehasSameRules in class TimeZoneother - the TimeZone object to be compared withpublic String getCanonicalID()
public void setID(String id)
TimeZonepublic int hashCode()
TimeZonepublic TimeZoneTransition getNextTransition(long base, boolean inclusive)
BasicTimeZoneExample code:
getNextTransition in class BasicTimeZonebase - 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)
BasicTimeZoneExample code:
getPreviousTransition in class BasicTimeZonebase - 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()
BasicTimeZoneTimeZoneRule 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 BasicTimeZoneTimeZoneRule which represents this
time zone.public boolean isFrozen()
TimeZonepublic TimeZone cloneAsThawed()
TimeZonecloneAsThawed in interface Freezable<TimeZone>cloneAsThawed in class TimeZone