Class TimeZone.Fixed

  • All Implemented Interfaces:
    java.io.Serializable, Calendrical
    Enclosing class:
    TimeZone

    static final class TimeZone.Fixed
    extends TimeZone
    Fixed time-zone.
    • 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.

        Specified by:
        getID in class TimeZone
        Returns:
        the time-zone unique ID, never null
      • 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 class TimeZone
        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 class TimeZone
        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 class TimeZone
        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 and OffsetTime are used in preference to fixed offset time-zones in ZonedDateTime.

        Specified by:
        isFixed in class TimeZone
        Returns:
        true if the time-zone is fixed and the offset never changes
      • 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 class TimeZone
        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 class TimeZone
        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 class TimeZone
        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 class TimeZone
        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 class TimeZone
        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 class TimeZone
        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 a TimeZone is loaded from a previously stored version but the rules are not available. In this case, the TimeZone instance is still valid, as is any associated object, such as ZonedDateTime. It is impossible to perform any calculations that require the rules however, and this method will throw an exception.

        Specified by:
        getGroup in class TimeZone
        Returns:
        the time-zone rules group ID, never null
      • 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.

        Specified by:
        isValid in class TimeZone
        Returns:
        true if this time-zone is valid and rules are available
      • 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.

        Specified by:
        getRules in class TimeZone
        Returns:
        the rules, never null
      • 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 class TimeZone
        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 class TimeZone
        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