Class FixedDateTimeZone
- java.lang.Object
-
- org.joda.time.DateTimeZone
-
- org.joda.time.tz.FixedDateTimeZone
-
- All Implemented Interfaces:
java.io.Serializable
public final class FixedDateTimeZone extends DateTimeZone
Basic DateTimeZone implementation that has a fixed name key and offsets.FixedDateTimeZone is thread-safe and immutable.
- Since:
- 1.0
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.joda.time.DateTimeZone
DEFAULT_TZ_DATA_PATH, UTC
-
-
Constructor Summary
Constructors Constructor Description FixedDateTimeZone(java.lang.String id, java.lang.String nameKey, int wallOffset, int standardOffset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
Compare this datetime zone with another.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
getOffsetFromLocal(long instantLocal)
Gets the millisecond offset to subtract from local time to get UTC time.int
getStandardOffset(long instant)
Gets the raw millisecond offset to add to UTC.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.java.util.TimeZone
toTimeZone()
Override to return the correct timezone instance.-
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, getProvider, getShortName, getShortName, isLocalDateTimeGap, isStandardOffset, setDefault, setNameProvider, setProvider, toString
-
-
-
-
Method Detail
-
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.This returns the actual offset from UTC for the zone at the specified instant. If the method is called with a different instant, the offset returned may be different as a result of daylight saving or other government rule changes.
- 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 raw millisecond offset to add to UTC.This should be treated as an implementation detail. End-users should use
DateTimeZone.getOffset(long)
.This returns the raw offset from UTC for the zone at the specified instant, effectively ignoring DST. If the method is called with a different instant, the offset returned may be different as a result of government rule changes.
This method should be named
getRawOffset()
but cannot be renamed for compatibility reasons.- 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
-
getOffsetFromLocal
public int getOffsetFromLocal(long instantLocal)
Description copied from class:DateTimeZone
Gets the millisecond offset to subtract from local time to get UTC time. This offset can be used to undo adding the offset obtained by getOffset.millisLocal == millisUTC + getOffset(millisUTC) millisUTC == millisLocal - getOffsetFromLocal(millisLocal)
NOTE: After calculating millisLocal, some error may be introduced. At offset transitions (due to DST or other historical changes), ranges of local times may map to different UTC times.For overlaps (where the local time is ambiguous), this method returns the offset applicable before the gap. The effect of this is that any instant calculated using the offset from an overlap will be in "summer" time.
For gaps, this method returns the offset applicable before the gap, ie "winter" offset. However, the effect of this is that any instant calculated using the offset from a gap will be after the gap, in "summer" time.
For example, consider a zone with a gap from 01:00 to 01:59:
Input: 00:00 (before gap) Output: Offset applicable before gap DateTime: 00:00
Input: 00:30 (before gap) Output: Offset applicable before gap DateTime: 00:30
Input: 01:00 (in gap) Output: Offset applicable before gap DateTime: 02:00
Input: 01:30 (in gap) Output: Offset applicable before gap DateTime: 02:30
Input: 02:00 (after gap) Output: Offset applicable after gap DateTime: 02:00
Input: 02:30 (after gap) Output: Offset applicable after gap DateTime: 02:30
NOTE: Prior to v2.0, the DST overlap behaviour was not defined and varied by hemisphere. Prior to v1.5, the DST gap behaviour was also not defined. In v2.4, the documentation was clarified again.
- Overrides:
getOffsetFromLocal
in classDateTimeZone
- Parameters:
instantLocal
- the millisecond instant, relative to this time zone, to get the offset for- Returns:
- the millisecond offset to subtract from local time to get UTC 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
-
toTimeZone
public java.util.TimeZone toTimeZone()
Override to return the correct timezone instance.- Overrides:
toTimeZone
in classDateTimeZone
- Returns:
- the closest matching TimeZone object
- Since:
- 1.5
-
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
-
hashCode
public int hashCode()
Description copied from class:DateTimeZone
Gets a hash code compatible with equals.- Overrides:
hashCode
in classDateTimeZone
- Returns:
- suitable hashcode
-
-