Class TimeZone.Fixed
- java.lang.Object
-
- javax.time.calendar.TimeZone
-
- javax.time.calendar.TimeZone.Fixed
-
- All Implemented Interfaces:
java.io.Serializable
,Calendrical
- Enclosing class:
- TimeZone
static final class TimeZone.Fixed extends TimeZone
Fixed time-zone.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.time.calendar.TimeZone
TimeZone.Fixed, TimeZone.ID, TimeZone.Rule
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
id
The zone id.private ZoneRules
rules
The zone rules.private static long
serialVersionUID
A serialization identifier for this class.-
Fields inherited from class javax.time.calendar.TimeZone
OLD_IDS_POST_2005, OLD_IDS_PRE_2005, UTC
-
-
Constructor Summary
Constructors Constructor Description Fixed(ZoneOffset offset)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ZoneRulesGroup
getGroup()
Finds the zone rules group for the stored group ID, such as 'TZDB'.java.lang.String
getGroupID()
Gets the time-zone rules group ID, such as 'TZDB'.java.lang.String
getID()
Gets the unique time-zone ID.java.lang.String
getRegionID()
Gets the time-zone region identifier, such as 'Europe/London'.ZoneRules
getRules()
Gets the time-zone rules allowing calculations to be performed.ZoneRules
getRulesValidFor(OffsetDateTime dateTime)
Gets the time-zone rules allowing calculations to be performed, ensuring that the date-time and offset specified is valid for the returned rules.java.lang.String
getVersionID()
Gets the time-zone rules group version, such as '2009b'.boolean
isFixed()
Checks of the time-zone is fixed, such that the offset never varies.boolean
isFloatingVersion()
Checks if the version is floating.boolean
isLatestVersion()
Checks if the version is the latest version.boolean
isValid()
Checks if this time-zone is valid such that rules can be obtained for it.boolean
isValidFor(OffsetDateTime dateTime)
Checks if this time-zone is valid such that rules can be obtained for it which are valid for the specified date-time and offset.private java.lang.Object
readResolve()
Handle deserialization.TimeZone
withFloatingVersion()
Returns a copy of this time-zone with a floating version.TimeZone
withLatestVersion()
Returns a copy of this time-zone with the latest available version ID.TimeZone
withLatestVersionValidFor(OffsetDateTime dateTime)
Returns a copy of this time-zone with the latest version that is valid for the specified date-time and offset.TimeZone
withVersion(java.lang.String versionID)
Returns a copy of this time-zone with the specified version ID.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
A serialization identifier for this class.- See Also:
- Constant Field Values
-
id
private final java.lang.String id
The zone id.
-
rules
private final transient ZoneRules rules
The zone rules.
-
-
Constructor Detail
-
Fixed
Fixed(ZoneOffset offset)
Constructor.- Parameters:
offset
- the offset, not null
-
-
Method Detail
-
readResolve
private java.lang.Object readResolve() throws java.io.ObjectStreamException
Handle deserialization.- Returns:
- the resolved instance, never null
- Throws:
java.io.ObjectStreamException
-
getID
public java.lang.String getID()
Description copied from class:TimeZone
Gets the unique time-zone ID.The unique key is created from the group ID, version ID and region ID. The format is {groupID}:{regionID}#{versionID}. If the group is 'TZDB' then the {groupID}: is omitted. If the version is floating, then the #{versionID} is omitted. Fixed time-zones will only output the region ID.
-
getGroupID
public java.lang.String getGroupID()
Description copied from class:TimeZone
Gets the time-zone rules group ID, such as 'TZDB'.The group ID is the first part of the
full unique ID
. Time zone rule data is supplied by a group, typically a company or organization. The default group is 'TZDB' representing the public time-zone database.For fixed time-zones, the group ID will be an empty string.
- Specified by:
getGroupID
in classTimeZone
- Returns:
- the time-zone rules group ID, never null
-
getRegionID
public java.lang.String getRegionID()
Description copied from class:TimeZone
Gets the time-zone region identifier, such as 'Europe/London'.The region ID is the second part of the
full unique ID
. Time zone rules are defined for a region and this element represents that region. The ID uses a format specific to the group. The default 'TZDB' group generally uses the format {area}/{city}, such as 'Europe/Paris'.- Specified by:
getRegionID
in classTimeZone
- Returns:
- the time-zone rules region ID, never null
-
getVersionID
public java.lang.String getVersionID()
Description copied from class:TimeZone
Gets the time-zone rules group version, such as '2009b'.The version ID is the third part of the
full unique ID
. Time zone rules change over time as governments change the associated laws. The time-zone groups capture these changes by issuing multiple versions of the data. An application can reference the exact set of rules used by using the group ID and version. Once loaded, there is no way to unload a version of the rules, however new versions may be added.The version can be an empty string which represents the floating version. This always uses the latest version of the rules available.
For fixed time-zones, the version ID will be an empty string.
- Specified by:
getVersionID
in classTimeZone
- Returns:
- the time-zone rules version ID, empty if the version is floating, never null
-
isFixed
public boolean isFixed()
Description copied from class:TimeZone
Checks of the time-zone is fixed, such that the offset never varies.It is intended that
OffsetDateTime
,OffsetDate
andOffsetTime
are used in preference to fixed offset time-zones inZonedDateTime
.
-
isFloatingVersion
public boolean isFloatingVersion()
Description copied from class:TimeZone
Checks if the version is floating.A floating version will track the latest available version of the rules.
For group based time-zones, this returns true if the version ID is empty, which is the definition of a floating zone.
For fixed time-zones, true is returned as the data is always the latest.
- Overrides:
isFloatingVersion
in classTimeZone
- Returns:
- true if the version is floating
-
withFloatingVersion
public TimeZone withFloatingVersion()
Description copied from class:TimeZone
Returns a copy of this time-zone with a floating version.For group based time-zones, this returns a
TimeZone
with the same group and region, but a floating version. The group and region IDs are not validated.For fixed time-zones,
this
is returned.- Specified by:
withFloatingVersion
in classTimeZone
- Returns:
- the new updated time-zone, never null
-
isLatestVersion
public boolean isLatestVersion()
Description copied from class:TimeZone
Checks if the version is the latest version.For floating group based time-zones, true is returned.
For non-floating group based time-zones, this returns true if the version stored is the same as the latest version available for the group and region. The group and region IDs are validated in order to calculate the latest version.
For fixed time-zones, true is returned.
- Specified by:
isLatestVersion
in classTimeZone
- Returns:
- true if the version is the latest available
-
withLatestVersion
public TimeZone withLatestVersion()
Description copied from class:TimeZone
Returns a copy of this time-zone with the latest available version ID.For floating and non-floating group based time-zones, this returns a zone with the same group and region, but the latest version that has been registered. The group and region IDs are validated in order to calculate the latest version.
For fixed time-zones,
this
is returned.- Specified by:
withLatestVersion
in classTimeZone
- Returns:
- the new updated time-zone, never null
-
withVersion
public TimeZone withVersion(java.lang.String versionID)
Description copied from class:TimeZone
Returns a copy of this time-zone with the specified version ID.For group based time-zones, this returns a
TimeZone
with the same group and region, but the specified version. The group and region IDs are validated to ensure that the version is valid.For fixed time-zones, the version must be an empty string, otherwise an exception is thrown.
- Specified by:
withVersion
in classTimeZone
- Parameters:
versionID
- the version ID to use, empty means floating version, not null- Returns:
- the new updated time-zone, never null
-
withLatestVersionValidFor
public TimeZone withLatestVersionValidFor(OffsetDateTime dateTime)
Description copied from class:TimeZone
Returns a copy of this time-zone with the latest version that is valid for the specified date-time and offset.This will search for a version of the time-zone rules that would make the specified date-time valid. This is needed for cases where the time-zone changes and you hold a reference to a date-time created before the rules changed.
This method validates the group and region IDs.
- Specified by:
withLatestVersionValidFor
in classTimeZone
- Parameters:
dateTime
- the date-time to get the latest version for- Returns:
- the new updated time-zone, never null
-
getGroup
public ZoneRulesGroup getGroup()
Description copied from class:TimeZone
Finds the zone rules group for the stored group ID, such as 'TZDB'.Time zone rules are provided by groups referenced by an ID.
Fixed time-zones are not provided by a group, thus this method throws an exception if the time-zone is fixed.
Callers of this method need to be aware of an unusual scenario. It is possible to obtain a
TimeZone
instance even when the rules are not available. This typically occurs when aTimeZone
is loaded from a previously stored version but the rules are not available. In this case, theTimeZone
instance is still valid, as is any associated object, such asZonedDateTime
. It is impossible to perform any calculations that require the rules however, and this method will throw an exception.
-
isValid
public boolean isValid()
Description copied from class:TimeZone
Checks if this time-zone is valid such that rules can be obtained for it.This will return true if the rules are available for the group, region and version ID combination. If this method returns true, then
TimeZone.getRules()
will return a valid rules instance.A time-zone can be invalid if it is deserialized in a JVM which does not have the same rules loaded as the JVM that stored it.
If this object declares a floating version of the rules and a background thread is used to update the available rules, then the result of calling this method may vary over time. Each individual call will be still remain thread-safe.
If this is a fixed time-zone, then it is always valid.
-
getRules
public ZoneRules getRules()
Description copied from class:TimeZone
Gets the time-zone rules allowing calculations to be performed.The rules provide the functionality associated with a time-zone, such as finding the offset for a given instant or local date-time. Different rules may be returned depending on the group, version and zone.
If this object declares a specific version of the rules, then the result will be of that version. If this object declares a floating version of the rules, then the latest version available will be returned.
A time-zone can be invalid if it is deserialized in a JVM which does not have the same rules loaded as the JVM that stored it. In this case, calling this method will throw an exception.
If this object declares a floating version of the rules and a background thread is used to update the available rules, then the result of calling this method may vary over time. Each individual call will be still remain thread-safe.
-
isValidFor
public boolean isValidFor(OffsetDateTime dateTime)
Description copied from class:TimeZone
Checks if this time-zone is valid such that rules can be obtained for it which are valid for the specified date-time and offset.This will return true if the rules are available for the group, region and version ID combination that are valid for the specified date-time. If this method returns true, then
TimeZone.getRulesValidFor(OffsetDateTime)
will return a valid rules instance.A time-zone can be invalid if it is deserialized in a JVM which does not have the same rules loaded as the JVM that stored it.
If this object declares a floating version of the rules and a background thread is used to update the available rules, then the result of calling this method may vary over time. Each individual call will be still remain thread-safe.
If this is a fixed time-zone, then it is valid if the offset matches the date-time.
- Specified by:
isValidFor
in classTimeZone
- Parameters:
dateTime
- a date-time for which the rules must be valid, null returns false- Returns:
- true if this time-zone is valid and rules are available
-
getRulesValidFor
public ZoneRules getRulesValidFor(OffsetDateTime dateTime)
Description copied from class:TimeZone
Gets the time-zone rules allowing calculations to be performed, ensuring that the date-time and offset specified is valid for the returned rules.The rules provide the functionality associated with a time-zone, such as finding the offset for a given instant or local date-time. Different rules may be returned depending on the group, version and zone.
If this object declares a specific version of the rules, then the result will be of that version providing that the specified date-time is valid for those rules. If this object declares a floating version of the rules, then the latest version of the rules where the date-time is valid will be returned.
A time-zone can be invalid if it is deserialized in a JVM which does not have the same rules loaded as the JVM that stored it. In this case, calling this method will throw an exception.
If this object declares a floating version of the rules and a background thread is used to update the available rules, then the result of calling this method may vary over time. Each individual call will be still remain thread-safe.
- Specified by:
getRulesValidFor
in classTimeZone
- Parameters:
dateTime
- a date-time for which the rules must be valid, not null- Returns:
- the latest rules for this zone where the date-time is valid, never null
-
-