Package org.joda.time

Class DateTimeZone

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    CachedDateTimeZone, DateTimeZoneBuilder.DSTZone, DateTimeZoneBuilder.PrecalculatedZone, FixedDateTimeZone, UTCDateTimeZone

    public abstract class DateTimeZone
    extends java.lang.Object
    implements java.io.Serializable
    DateTimeZone represents a time zone.

    A time zone is a system of rules to convert time from one geographic location to another. For example, Paris, France is one hour ahead of London, England. Thus when it is 10:00 in London, it is 11:00 in Paris.

    All time zone rules are expressed, for historical reasons, relative to Greenwich, London. Local time in Greenwich is referred to as Greenwich Mean Time (GMT). This is similar, but not precisely identical, to Universal Coordinated Time, or UTC. This library only uses the term UTC.

    Using this system, America/Los_Angeles is expressed as UTC-08:00, or UTC-07:00 in the summer. The offset -08:00 indicates that America/Los_Angeles time is obtained from UTC by adding -08:00, that is, by subtracting 8 hours.

    The offset differs in the summer because of daylight saving time, or DST. The following definitions of time are generally used:

    • UTC - The reference time.
    • Standard Time - The local time without a daylight saving time offset. For example, in Paris, standard time is UTC+01:00.
    • Daylight Saving Time - The local time with a daylight saving time offset. This offset is typically one hour, but not always. It is typically used in most countries away from the equator. In Paris, daylight saving time is UTC+02:00.
    • Wall Time - This is what a local clock on the wall reads. This will be either Standard Time or Daylight Saving Time depending on the time of year and whether the location uses Daylight Saving Time.

    Unlike the Java TimeZone class, DateTimeZone is immutable. It also only supports long format time zone ids. Thus EST and ECT are not accepted. However, the factory that accepts a TimeZone will attempt to convert from the old short id to a suitable long id.

    There are four approaches to loading time-zone data, which are tried in this order:

    1. load the specific Provider specified by the system property org.joda.time.DateTimeZone.Provider.
    2. load ZoneInfoProvider using the data in the filing system folder pointed to by system property org.joda.time.DateTimeZone.Folder.
    3. load ZoneInfoProvider using the data in the classpath location org/joda/time/tz/data.
    4. load UTCProvider

    Unless you override the standard behaviour, the default if the third approach.

    DateTimeZone is thread-safe and immutable, and all subclasses must be as well.

    Since:
    1.0
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  DateTimeZone.LazyInit
      Lazy initialization to avoid a synchronization lock.
      private static class  DateTimeZone.Stub
      Used to serialize DateTimeZones by id.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.concurrent.atomic.AtomicReference<DateTimeZone> cDefault
      The default time zone.
      private static java.util.concurrent.atomic.AtomicReference<NameProvider> cNameProvider
      The instance that is providing time zone names.
      private static java.util.concurrent.atomic.AtomicReference<Provider> cProvider
      The instance that is providing time zones.
      private java.lang.String iID  
      private static int MAX_MILLIS
      Maximum offset.
      private static long serialVersionUID
      Serialization version.
      static DateTimeZone UTC
      The time zone for Universal Coordinated Time
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected DateTimeZone​(java.lang.String id)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      long adjustOffset​(long instant, boolean earlierOrLater)
      Adjusts the offset to be the earlier or later one during an overlap.
      long convertLocalToUTC​(long instantLocal, boolean strict)
      Converts a local instant to a standard UTC instant with the same local time.
      long convertLocalToUTC​(long instantLocal, boolean strict, long originalInstantUTC)
      Converts a local instant to a standard UTC instant with the same local time attempting to use the same offset as the original.
      private static java.lang.String convertToAsciiNumber​(java.lang.String convId)  
      long convertUTCToLocal​(long instantUTC)
      Converts a standard UTC instant to a local instant with the same local time.
      abstract boolean equals​(java.lang.Object object)
      Compare this datetime zone with another.
      private static DateTimeZone fixedOffsetZone​(java.lang.String id, int offset)
      Gets the zone using a fixed offset amount.
      static DateTimeZone forID​(java.lang.String id)
      Gets a time zone instance for the specified time zone id.
      static DateTimeZone forOffsetHours​(int hoursOffset)
      Gets a time zone instance for the specified offset to UTC in hours.
      static DateTimeZone forOffsetHoursMinutes​(int hoursOffset, int minutesOffset)
      Gets a time zone instance for the specified offset to UTC in hours and minutes.
      static DateTimeZone forOffsetMillis​(int millisOffset)
      Gets a time zone instance for the specified offset to UTC in milliseconds.
      static DateTimeZone forTimeZone​(java.util.TimeZone zone)
      Gets a time zone instance for a JDK TimeZone.
      static java.util.Set<java.lang.String> getAvailableIDs()
      Gets all the available IDs supported.
      private static java.lang.String getConvertedId​(java.lang.String id)
      Converts an old style id to a new style id.
      static DateTimeZone getDefault()
      Gets the default time zone.
      private static NameProvider getDefaultNameProvider()
      Gets the default name provider.
      private static Provider getDefaultProvider()
      Gets the default zone provider.
      java.lang.String getID()
      Gets the ID of this datetime zone.
      long getMillisKeepLocal​(DateTimeZone newZone, long oldInstant)
      Gets the millisecond instant in another zone keeping the same local time.
      java.lang.String getName​(long instant)
      Gets the long name of this datetime zone suitable for display using the default locale.
      java.lang.String getName​(long instant, java.util.Locale locale)
      Gets the long name of this datetime zone suitable for display using the specified locale.
      abstract java.lang.String getNameKey​(long instant)
      Returns a non-localized name that is unique to this time zone.
      static NameProvider getNameProvider()
      Gets the name provider factory.
      abstract int getOffset​(long instant)
      Gets the millisecond offset to add to UTC to get local time.
      int getOffset​(ReadableInstant 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.
      static Provider getProvider()
      Gets the zone provider factory.
      java.lang.String getShortName​(long instant)
      Gets the short name of this datetime zone suitable for display using the default locale.
      java.lang.String getShortName​(long instant, java.util.Locale locale)
      Gets the short name of this datetime zone suitable for display using the specified locale.
      abstract int getStandardOffset​(long instant)
      Gets the standard millisecond offset to add to UTC to get local time, when standard time is in effect.
      int hashCode()
      Gets a hash code compatible with equals.
      abstract boolean isFixed()
      Returns true if this time zone has no transitions.
      boolean isLocalDateTimeGap​(LocalDateTime localDateTime)
      Checks if the given LocalDateTime is within a gap.
      boolean isStandardOffset​(long instant)
      Checks whether, at a particular instant, the offset is standard or not.
      abstract long nextTransition​(long instant)
      Advances the given instant to where the time zone offset or name changes.
      private static int parseOffset​(java.lang.String str)
      Parses an offset from the string.
      abstract long previousTransition​(long instant)
      Retreats the given instant to where the time zone offset or name changes.
      private static java.lang.String printOffset​(int offset)
      Formats a timezone offset string.
      static void setDefault​(DateTimeZone zone)
      Sets the default time zone.
      static void setNameProvider​(NameProvider nameProvider)
      Sets the name provider factory.
      static void setProvider​(Provider provider)
      Sets the zone provider factory.
      java.lang.String toString()
      Gets the datetime zone as a string, which is simply its ID.
      java.util.TimeZone toTimeZone()
      Get the datetime zone as a TimeZone.
      private static Provider validateProvider​(Provider provider)
      Sets the zone provider factory without performing the security check.
      protected java.lang.Object writeReplace()
      By default, when DateTimeZones are serialized, only a "stub" object referring to the id is written out.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Serialization version.
        See Also:
        Constant Field Values
      • UTC

        public static final DateTimeZone UTC
        The time zone for Universal Coordinated Time
      • cProvider

        private static final java.util.concurrent.atomic.AtomicReference<Provider> cProvider
        The instance that is providing time zones. This is lazily initialized to reduce risks of race conditions at startup.
      • cNameProvider

        private static final java.util.concurrent.atomic.AtomicReference<NameProvider> cNameProvider
        The instance that is providing time zone names. This is lazily initialized to reduce risks of race conditions at startup.
      • cDefault

        private static final java.util.concurrent.atomic.AtomicReference<DateTimeZone> cDefault
        The default time zone. This is lazily initialized to reduce risks of race conditions at startup.
      • iID

        private final java.lang.String iID
    • Constructor Detail

      • DateTimeZone

        protected DateTimeZone​(java.lang.String id)
        Constructor.
        Parameters:
        id - the id to use
        Throws:
        java.lang.IllegalArgumentException - if the id is null
    • Method Detail

      • getDefault

        public static DateTimeZone getDefault()
        Gets the default time zone.

        The default time zone is derived from the system property user.timezone. If that is null or is not a valid identifier, then the value of the JDK TimeZone default is converted. If that fails, UTC is used.

        NOTE: If the java.util.TimeZone default is updated after calling this method, then the change will not be picked up here.

        Returns:
        the default datetime zone object
      • setDefault

        public static void setDefault​(DateTimeZone zone)
                               throws java.lang.SecurityException
        Sets the default time zone.

        NOTE: Calling this method does not set the java.util.TimeZone default.

        Parameters:
        zone - the default datetime zone object, must not be null
        Throws:
        java.lang.IllegalArgumentException - if the zone is null
        java.lang.SecurityException - if the application has insufficient security rights
      • forID

        public static DateTimeZone forID​(java.lang.String id)
        Gets a time zone instance for the specified time zone id.

        The time zone id may be one of those returned by getAvailableIDs. Short ids, as accepted by TimeZone, are not accepted. All IDs must be specified in the long format. The exception is UTC, which is an acceptable id.

        Alternatively a locale independent, fixed offset, datetime zone can be specified. The form [+-]hh:mm can be used.

        Parameters:
        id - the ID of the datetime zone, null means default
        Returns:
        the DateTimeZone object for the ID
        Throws:
        java.lang.IllegalArgumentException - if the ID is not recognised
      • forOffsetHours

        public static DateTimeZone forOffsetHours​(int hoursOffset)
                                           throws java.lang.IllegalArgumentException
        Gets a time zone instance for the specified offset to UTC in hours. This method assumes standard length hours.

        This factory is a convenient way of constructing zones with a fixed offset.

        Parameters:
        hoursOffset - the offset in hours from UTC, from -23 to +23
        Returns:
        the DateTimeZone object for the offset
        Throws:
        java.lang.IllegalArgumentException - if the offset is too large or too small
      • forOffsetHoursMinutes

        public static DateTimeZone forOffsetHoursMinutes​(int hoursOffset,
                                                         int minutesOffset)
                                                  throws java.lang.IllegalArgumentException
        Gets a time zone instance for the specified offset to UTC in hours and minutes. This method assumes 60 minutes in an hour, and standard length minutes.

        This factory is a convenient way of constructing zones with a fixed offset. The hours value must be in the range -23 to +23. The minutes value must be in the range -59 to +59. The following combinations of sign for the hour and minute are possible:

          Hour    Minute    Example    Result
         
          +ve     +ve       (2, 15)    +02:15
          +ve     zero      (2, 0)     +02:00
          +ve     -ve       (2, -15)   IllegalArgumentException
         
          zero    +ve       (0, 15)    +00:15
          zero    zero      (0, 0)     +00:00
          zero    -ve       (0, -15)   -00:15
         
          -ve     +ve       (-2, 15)   -02:15
          -ve     zero      (-2, 0)    -02:00
          -ve     -ve       (-2, -15)  -02:15
         
        Note that in versions before 2.3, the minutes had to be zero or positive.
        Parameters:
        hoursOffset - the offset in hours from UTC, from -23 to +23
        minutesOffset - the offset in minutes from UTC, from -59 to +59
        Returns:
        the DateTimeZone object for the offset
        Throws:
        java.lang.IllegalArgumentException - if any value is out of range, the minutes are negative when the hours are positive, or the resulting offset exceeds +/- 23:59:59.000
      • forOffsetMillis

        public static DateTimeZone forOffsetMillis​(int millisOffset)
        Gets a time zone instance for the specified offset to UTC in milliseconds.
        Parameters:
        millisOffset - the offset in millis from UTC, from -23:59:59.999 to +23:59:59.999
        Returns:
        the DateTimeZone object for the offset
      • forTimeZone

        public static DateTimeZone forTimeZone​(java.util.TimeZone zone)
        Gets a time zone instance for a JDK TimeZone.

        DateTimeZone only accepts a subset of the IDs from TimeZone. The excluded IDs are the short three letter form (except UTC). This method will attempt to convert between time zones created using the short IDs and the full version.

        This method is not designed to parse time zones with rules created by applications using SimpleTimeZone directly.

        Parameters:
        zone - the zone to convert, null means default
        Returns:
        the DateTimeZone object for the zone
        Throws:
        java.lang.IllegalArgumentException - if the zone is not recognised
      • convertToAsciiNumber

        private static java.lang.String convertToAsciiNumber​(java.lang.String convId)
      • fixedOffsetZone

        private static DateTimeZone fixedOffsetZone​(java.lang.String id,
                                                    int offset)
        Gets the zone using a fixed offset amount.
        Parameters:
        id - the zone id
        offset - the offset in millis
        Returns:
        the zone
      • getAvailableIDs

        public static java.util.Set<java.lang.String> getAvailableIDs()
        Gets all the available IDs supported.
        Returns:
        an unmodifiable Set of String IDs
      • getProvider

        public static Provider getProvider()
        Gets the zone provider factory.

        The zone provider is a pluggable instance factory that supplies the actual instances of DateTimeZone.

        Returns:
        the provider
      • setProvider

        public static void setProvider​(Provider provider)
                                throws java.lang.SecurityException
        Sets the zone provider factory.

        The zone provider is a pluggable instance factory that supplies the actual instances of DateTimeZone.

        Parameters:
        provider - provider to use, or null for default
        Throws:
        java.lang.SecurityException - if you do not have the permission DateTimeZone.setProvider
        java.lang.IllegalArgumentException - if the provider is invalid
      • validateProvider

        private static Provider validateProvider​(Provider provider)
        Sets the zone provider factory without performing the security check.
        Parameters:
        provider - provider to use, or null for default
        Returns:
        the provider
        Throws:
        java.lang.IllegalArgumentException - if the provider is invalid
      • getDefaultProvider

        private static Provider getDefaultProvider()
        Gets the default zone provider.

        This tries four approaches to loading data:

        1. loads the provider identifier by the system property org.joda.time.DateTimeZone.Provider.
        2. load ZoneInfoProvider using the data in the filing system folder pointed to by system property org.joda.time.DateTimeZone.Folder.
        3. loads ZoneInfoProvider using the data in the classpath location org/joda/time/tz/data.
        4. loads UTCProvider.

        Unless you override the standard behaviour, the default if the third approach.

        Returns:
        the default name provider
      • getNameProvider

        public static NameProvider getNameProvider()
        Gets the name provider factory.

        The name provider is a pluggable instance factory that supplies the names of each DateTimeZone.

        Returns:
        the provider
      • setNameProvider

        public static void setNameProvider​(NameProvider nameProvider)
                                    throws java.lang.SecurityException
        Sets the name provider factory.

        The name provider is a pluggable instance factory that supplies the names of each DateTimeZone.

        Parameters:
        nameProvider - provider to use, or null for default
        Throws:
        java.lang.SecurityException - if you do not have the permission DateTimeZone.setNameProvider
        java.lang.IllegalArgumentException - if the provider is invalid
      • getDefaultNameProvider

        private static NameProvider getDefaultNameProvider()
        Gets the default name provider.

        Tries the system property org.joda.time.DateTimeZone.NameProvider. Then uses DefaultNameProvider.

        Returns:
        the default name provider
      • getConvertedId

        private static java.lang.String getConvertedId​(java.lang.String id)
        Converts an old style id to a new style id.
        Parameters:
        id - the old style id
        Returns:
        the new style id, null if not found
      • parseOffset

        private static int parseOffset​(java.lang.String str)
        Parses an offset from the string.
        Parameters:
        str - the string
        Returns:
        the offset millis
      • printOffset

        private static java.lang.String printOffset​(int offset)
        Formats a timezone offset string.

        This method is kept separate from the formatting classes to speed and simplify startup and classloading.

        Parameters:
        offset - the offset in milliseconds
        Returns:
        the time zone string
      • getID

        public final java.lang.String getID()
        Gets the ID of this datetime zone.
        Returns:
        the ID of this datetime zone
      • getNameKey

        public abstract java.lang.String getNameKey​(long instant)
        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.
        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
      • getShortName

        public final java.lang.String getShortName​(long instant)
        Gets the short name of this datetime zone suitable for display using the default locale.

        If the name is not available for the locale, then this method returns a string in the format [+-]hh:mm.

        Parameters:
        instant - milliseconds from 1970-01-01T00:00:00Z to get the name for
        Returns:
        the human-readable short name in the default locale
      • getShortName

        public java.lang.String getShortName​(long instant,
                                             java.util.Locale locale)
        Gets the short name of this datetime zone suitable for display using the specified locale.

        If the name is not available for the locale, then this method returns a string in the format [+-]hh:mm.

        Parameters:
        instant - milliseconds from 1970-01-01T00:00:00Z to get the name for
        locale - the locale to get the name for
        Returns:
        the human-readable short name in the specified locale
      • getName

        public final java.lang.String getName​(long instant)
        Gets the long name of this datetime zone suitable for display using the default locale.

        If the name is not available for the locale, then this method returns a string in the format [+-]hh:mm.

        Parameters:
        instant - milliseconds from 1970-01-01T00:00:00Z to get the name for
        Returns:
        the human-readable long name in the default locale
      • getName

        public java.lang.String getName​(long instant,
                                        java.util.Locale locale)
        Gets the long name of this datetime zone suitable for display using the specified locale.

        If the name is not available for the locale, then this method returns a string in the format [+-]hh:mm.

        Parameters:
        instant - milliseconds from 1970-01-01T00:00:00Z to get the name for
        locale - the locale to get the name for
        Returns:
        the human-readable long name in the specified locale
      • getOffset

        public abstract int getOffset​(long instant)
        Gets the millisecond offset to add to UTC to get local time.
        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
      • getOffset

        public final int getOffset​(ReadableInstant instant)
        Gets the millisecond offset to add to UTC to get local time.
        Parameters:
        instant - instant to get the offset for, null means now
        Returns:
        the millisecond offset to add to UTC to get local time
      • getStandardOffset

        public abstract int getStandardOffset​(long instant)
        Gets the standard millisecond offset to add to UTC to get local time, when standard time is in effect.
        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
      • isStandardOffset

        public boolean isStandardOffset​(long instant)
        Checks whether, at a particular instant, the offset is standard or not.

        This method can be used to determine whether Summer Time (DST) applies. As a general rule, if the offset at the specified instant is standard, then either Winter time applies, or there is no Summer Time. If the instant is not standard, then Summer Time applies.

        The implementation of the method is simply whether getOffset(long) equals getStandardOffset(long) at the specified instant.

        Parameters:
        instant - milliseconds from 1970-01-01T00:00:00Z to get the offset for
        Returns:
        true if the offset at the given instant is the standard offset
        Since:
        1.5
      • getOffsetFromLocal

        public int getOffsetFromLocal​(long instantLocal)
        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.

        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
      • convertUTCToLocal

        public long convertUTCToLocal​(long instantUTC)
        Converts a standard UTC instant to a local instant with the same local time. This conversion is used before performing a calculation so that the calculation can be done using a simple local zone.
        Parameters:
        instantUTC - the UTC instant to convert to local
        Returns:
        the local instant with the same local time
        Throws:
        java.lang.ArithmeticException - if the result overflows a long
        Since:
        1.5
      • convertLocalToUTC

        public long convertLocalToUTC​(long instantLocal,
                                      boolean strict,
                                      long originalInstantUTC)
        Converts a local instant to a standard UTC instant with the same local time attempting to use the same offset as the original.

        This conversion is used after performing a calculation where the calculation was done using a simple local zone. Whenever possible, the same offset as the original offset will be used. This is most significant during a daylight savings overlap.

        Parameters:
        instantLocal - the local instant to convert to UTC
        strict - whether the conversion should reject non-existent local times
        originalInstantUTC - the original instant that the calculation is based on
        Returns:
        the UTC instant with the same local time,
        Throws:
        java.lang.ArithmeticException - if the result overflows a long
        java.lang.IllegalArgumentException - if the zone has no equivalent local time
        Since:
        2.0
      • convertLocalToUTC

        public long convertLocalToUTC​(long instantLocal,
                                      boolean strict)
        Converts a local instant to a standard UTC instant with the same local time. This conversion is used after performing a calculation where the calculation was done using a simple local zone.
        Parameters:
        instantLocal - the local instant to convert to UTC
        strict - whether the conversion should reject non-existent local times
        Returns:
        the UTC instant with the same local time,
        Throws:
        java.lang.ArithmeticException - if the result overflows a long
        IllegalInstantException - if the zone has no equivalent local time
        Since:
        1.5
      • getMillisKeepLocal

        public long getMillisKeepLocal​(DateTimeZone newZone,
                                       long oldInstant)
        Gets the millisecond instant in another zone keeping the same local time.

        The conversion is performed by converting the specified UTC millis to local millis in this zone, then converting back to UTC millis in the new zone.

        Parameters:
        newZone - the new zone, null means default
        oldInstant - the UTC millisecond instant to convert
        Returns:
        the UTC millisecond instant with the same local time in the new zone
      • isLocalDateTimeGap

        public boolean isLocalDateTimeGap​(LocalDateTime localDateTime)
        Checks if the given LocalDateTime is within a gap.

        When switching from standard time to Daylight Savings Time there is typically a gap where a clock hour is missing. This method identifies whether the local datetime refers to such a gap.

        Parameters:
        localDateTime - the time to check, not null
        Returns:
        true if the given datetime refers to a gap
        Since:
        1.6
      • adjustOffset

        public long adjustOffset​(long instant,
                                 boolean earlierOrLater)
        Adjusts the offset to be the earlier or later one during an overlap.
        Parameters:
        instant - the instant to adjust
        earlierOrLater - false for earlier, true for later
        Returns:
        the adjusted instant millis
      • isFixed

        public abstract boolean isFixed()
        Returns true if this time zone has no transitions.
        Returns:
        true if no transitions
      • nextTransition

        public abstract long nextTransition​(long instant)
        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.
        Parameters:
        instant - milliseconds from 1970-01-01T00:00:00Z
        Returns:
        milliseconds from 1970-01-01T00:00:00Z
      • previousTransition

        public abstract long previousTransition​(long instant)
        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.
        Parameters:
        instant - milliseconds from 1970-01-01T00:00:00Z
        Returns:
        milliseconds from 1970-01-01T00:00:00Z
      • toTimeZone

        public java.util.TimeZone toTimeZone()
        Get the datetime zone as a TimeZone.
        Returns:
        the closest matching TimeZone object
      • equals

        public abstract boolean equals​(java.lang.Object object)
        Compare this datetime zone with another.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        object - the object to compare with
        Returns:
        true if equal, based on the ID and all internal rules
      • hashCode

        public int hashCode()
        Gets a hash code compatible with equals.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        suitable hashcode
      • toString

        public java.lang.String toString()
        Gets the datetime zone as a string, which is simply its ID.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the id of the zone
      • writeReplace

        protected java.lang.Object writeReplace()
                                         throws java.io.ObjectStreamException
        By default, when DateTimeZones are serialized, only a "stub" object referring to the id is written out. When the stub is read in, it replaces itself with a DateTimeZone object.
        Returns:
        a stub object to go in the stream
        Throws:
        java.io.ObjectStreamException