Package org.teavm.classlib.impl.tz
Class CachedDateTimeZone
java.lang.Object
org.teavm.classlib.impl.tz.DateTimeZone
org.teavm.classlib.impl.tz.StorableDateTimeZone
org.teavm.classlib.impl.tz.CachedDateTimeZone
Improves the performance of requesting time zone offsets and name keys by
caching the results. Time zones that have simple rules or are fixed should
not be cached, as it is unlikely to improve performance.
CachedDateTimeZone is thread-safe and immutable.
- Since:
- 1.0
-
Field Summary
Fields inherited from class org.teavm.classlib.impl.tz.StorableDateTimeZone
ALIAS, DST, FIXED, PRECALCULATED, RULE_BASED -
Method Summary
Modifier and TypeMethodDescriptionstatic CachedDateTimeZoneforZone(StorableDateTimeZone zone) Returns a new CachedDateTimeZone unless given zone is already cached.intgetOffset(long instant) Gets the millisecond offset to add to UTC to get local time.intgetStandardOffset(long instant) Gets the standard millisecond offset to add to UTC to get local time, when standard time is in effect.Returns the DateTimeZone being wrapped.booleanisFixed()Returns true if this time zone has no transitions.longnextTransition(long instant) Advances the given instant to where the time zone offset or name changes.longpreviousTransition(long instant) Retreats the given instant to where the time zone offset or name changes.voidwrite(StringBuilder sb) Methods inherited from class org.teavm.classlib.impl.tz.StorableDateTimeZone
read, readTime, readTimeArray, readUnsignedTime, writeTime, writeTimeArray, writeUnsignedTimeMethods inherited from class org.teavm.classlib.impl.tz.DateTimeZone
adjustOffset, convertLocalToUTC, convertLocalToUTC, convertUTCToLocal, getID, getMillisKeepLocal, getOffsetFromLocal, isStandardOffset
-
Method Details
-
forZone
Returns a new CachedDateTimeZone unless given zone is already cached. -
write
- Specified by:
writein classStorableDateTimeZone
-
getUncachedZone
Returns the DateTimeZone being wrapped. -
getOffset
public int getOffset(long instant) Description copied from class:DateTimeZoneGets the millisecond offset to add to UTC to get local time.- Specified by:
getOffsetin classDateTimeZone- Parameters:
instant- milliseconds from 1970-01-01T00:00:00Z to get the offset for- Returns:
- the millisecond offset to add to UTC to get local time
-
getStandardOffset
public int getStandardOffset(long instant) Description copied from class:DateTimeZoneGets the standard millisecond offset to add to UTC to get local time, when standard time is in effect.- Specified by:
getStandardOffsetin classDateTimeZone- Parameters:
instant- milliseconds from 1970-01-01T00:00:00Z to get the offset for- Returns:
- the millisecond offset to add to UTC to get local time
-
isFixed
public boolean isFixed()Description copied from class:DateTimeZoneReturns true if this time zone has no transitions.- Specified by:
isFixedin classDateTimeZone- Returns:
- true if no transitions
-
nextTransition
public long nextTransition(long instant) Description copied from class:DateTimeZoneAdvances the given instant to where the time zone offset or name changes. If the instant returned is exactly the same as passed in, then no changes occur after the given instant.- Specified by:
nextTransitionin classDateTimeZone- Parameters:
instant- milliseconds from 1970-01-01T00:00:00Z- Returns:
- milliseconds from 1970-01-01T00:00:00Z
-
previousTransition
public long previousTransition(long instant) Description copied from class:DateTimeZoneRetreats the given instant to where the time zone offset or name changes. If the instant returned is exactly the same as passed in, then no changes occur before the given instant.- Specified by:
previousTransitionin classDateTimeZone- Parameters:
instant- milliseconds from 1970-01-01T00:00:00Z- Returns:
- milliseconds from 1970-01-01T00:00:00Z
-
asZoneRules
- Specified by:
asZoneRulesin classDateTimeZone
-