Package org.joda.time.tz
Class CachedDateTimeZone
- java.lang.Object
-
- org.joda.time.DateTimeZone
-
- org.joda.time.tz.CachedDateTimeZone
-
- All Implemented Interfaces:
java.io.Serializable
public class CachedDateTimeZone extends DateTimeZone
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
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CachedDateTimeZone.Info
-
Field Summary
Fields Modifier and Type Field Description private static int
cInfoCacheMask
private CachedDateTimeZone.Info[]
iInfoCache
private DateTimeZone
iZone
private static long
serialVersionUID
-
Fields inherited from class org.joda.time.DateTimeZone
UTC
-
-
Constructor Summary
Constructors Modifier Constructor Description private
CachedDateTimeZone(DateTimeZone zone)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private CachedDateTimeZone.Info
createInfo(long millis)
boolean
equals(java.lang.Object obj)
Compare this datetime zone with another.static CachedDateTimeZone
forZone(DateTimeZone zone)
Returns a new CachedDateTimeZone unless given zone is already cached.private CachedDateTimeZone.Info
getInfo(long millis)
java.lang.String
getNameKey(long instant)
Returns a non-localized name that is unique to this time zone.int
getOffset(long instant)
Gets the millisecond offset to add to UTC to get local time.int
getStandardOffset(long instant)
Gets the standard millisecond offset to add to UTC to get local time, when standard time is in effect.DateTimeZone
getUncachedZone()
Returns the DateTimeZone being wrapped.int
hashCode()
Gets a hash code compatible with equals.boolean
isFixed()
Returns true if this time zone has no transitions.long
nextTransition(long instant)
Advances the given instant to where the time zone offset or name changes.long
previousTransition(long instant)
Retreats the given instant to where the time zone offset or name changes.-
Methods inherited from class org.joda.time.DateTimeZone
adjustOffset, convertLocalToUTC, convertLocalToUTC, convertUTCToLocal, forID, forOffsetHours, forOffsetHoursMinutes, forOffsetMillis, forTimeZone, getAvailableIDs, getDefault, getID, getMillisKeepLocal, getName, getName, getNameProvider, getOffset, getOffsetFromLocal, getProvider, getShortName, getShortName, isLocalDateTimeGap, isStandardOffset, setDefault, setNameProvider, setProvider, toString, toTimeZone, writeReplace
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
cInfoCacheMask
private static final int cInfoCacheMask
-
iZone
private final DateTimeZone iZone
-
iInfoCache
private final transient CachedDateTimeZone.Info[] iInfoCache
-
-
Constructor Detail
-
CachedDateTimeZone
private CachedDateTimeZone(DateTimeZone zone)
-
-
Method Detail
-
forZone
public static CachedDateTimeZone forZone(DateTimeZone zone)
Returns a new CachedDateTimeZone unless given zone is already cached.
-
getUncachedZone
public DateTimeZone getUncachedZone()
Returns the DateTimeZone being wrapped.
-
getNameKey
public java.lang.String getNameKey(long instant)
Description copied from class:DateTimeZone
Returns a non-localized name that is unique to this time zone. It can be combined with id to form a unique key for fetching localized names.- Specified by:
getNameKey
in classDateTimeZone
- Parameters:
instant
- milliseconds from 1970-01-01T00:00:00Z to get the name for- Returns:
- name key or null if id should be used for names
-
getOffset
public int getOffset(long instant)
Description copied from class:DateTimeZone
Gets the millisecond offset to add to UTC to get local time.- Specified by:
getOffset
in 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:DateTimeZone
Gets the standard millisecond offset to add to UTC to get local time, when standard time is in effect.- Specified by:
getStandardOffset
in 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:DateTimeZone
Returns true if this time zone has no transitions.- Specified by:
isFixed
in classDateTimeZone
- Returns:
- true if no transitions
-
nextTransition
public long nextTransition(long instant)
Description copied from class:DateTimeZone
Advances 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:
nextTransition
in 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:DateTimeZone
Retreats 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:
previousTransition
in classDateTimeZone
- Parameters:
instant
- milliseconds from 1970-01-01T00:00:00Z- Returns:
- milliseconds from 1970-01-01T00:00:00Z
-
hashCode
public int hashCode()
Description copied from class:DateTimeZone
Gets a hash code compatible with equals.- Overrides:
hashCode
in classDateTimeZone
- Returns:
- suitable hashcode
-
equals
public boolean equals(java.lang.Object obj)
Description copied from class:DateTimeZone
Compare this datetime zone with another.- Specified by:
equals
in classDateTimeZone
- Parameters:
obj
- the object to compare with- Returns:
- true if equal, based on the ID and all internal rules
-
getInfo
private CachedDateTimeZone.Info getInfo(long millis)
-
createInfo
private CachedDateTimeZone.Info createInfo(long millis)
-
-