Package net.time4j.tz

Class ZonalTransition

java.lang.Object
net.time4j.tz.ZonalTransition
All Implemented Interfaces:
Serializable, Comparable<ZonalTransition>

public final class ZonalTransition extends Object implements Comparable<ZonalTransition>, Serializable

Represents the change of a shift of the local time relative to POSIX-time in any timezone.

This class contains informations about the global timestamp of the transition and the shifts/offsets before and after the transitions. A change of a zonal shift can either be caused by special historical events and political actions (change of raw time) or by establishing daylight saving-rules (change from winter time to summer time and reverse - DST). Therefore the total shift getTotalOffset() is always the sum of the parts getRawOffset() and getExtraOffset().

Shifts are described on the local timeline in seconds. Following relationship holds between local time and POSIX-time:

getTotalOffset() = [Local Wall Time] - [POSIX Time]

A zonal transition induces a gap on the local timeline if the new shift is greater than the old shift. And an overlap occurs if the new shift is smaller than the old shift. A local time is not defined within gaps and ambivalent in overlapping regions.

Author:
Meno Hochschild
See Also:
Serialized Form
  • Constructor Summary

    Constructors
    Constructor
    Description
    ZonalTransition​(long posixTime, int previousOffset, int totalOffset, int extraOffset)
    Creates a new transition between two shifts.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Compares preferrably the timeline order based on the global timestamps of transitions, otherwise the total shift and finally the extra shift.
    boolean
    equals​(Object obj)
    Based on the whole state with global POSIX-timestamp and all internal shifts.
    int
    Deprecated.
    method was renamed and is subject to removal in future versions
    int
    Returns typically the DST-shift (daylight savings) after this transition that is the shift normally induced by change to summer time.
    long
    Returns the global timestamp of this transition from one shift to another as POSIX-timestamp.
    int
    Returns the total shift before this transition.
    int
    Returns the raw shift after this transition as difference between total shift and an extra shift (often daylight savings).
    int
    Gets the difference between new and old total shift as measure for the size of this transition.
    int
    Deprecated.
    method was renamed and is subject to removal in future versions
    int
    Returns the total shift after this transition.
    int
    Based on the POSIX-timestamp of the transition.
    boolean
    Queries if this transition represents a gap on the local timeline where local timestamps are invalid.
    boolean
    Queries if this transition represents an overlap on the local timeline where local timestamps are ambivalent.
    Supports debugging.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ZonalTransition

      public ZonalTransition(long posixTime, int previousOffset, int totalOffset, int extraOffset)

      Creates a new transition between two shifts.

      The given daylight-saving offset might be exceptionally equal to Integer.MAX_VALUE which signals an offset of zero but interpreted as daylight-saving. This special feature is supported since version v3.39/4.34.

      Parameters:
      posixTime - POSIX time of transition
      previousOffset - previous total shift in seconds
      totalOffset - new total shift in seconds
      extraOffset - extra shift in seconds
      Throws:
      IllegalArgumentException - if any offset is out of range -18 * 3600 <= total <= 18 * 3600
      See Also:
      UnixTime.getPosixTime(), ZonalOffset.getIntegralAmount()
  • Method Details

    • getPosixTime

      public long getPosixTime()

      Returns the global timestamp of this transition from one shift to another as POSIX-timestamp.

      Returns:
      transition time relative to [1970-01-01T00:00:00] in seconds (without leap seconds)
      See Also:
      TimeScale.POSIX
    • getPreviousOffset

      public int getPreviousOffset()

      Returns the total shift before this transition.

      Returns:
      previous total shift in seconds
      See Also:
      getTotalOffset(), ZonalOffset.getIntegralAmount()
    • getTotalOffset

      public int getTotalOffset()

      Returns the total shift after this transition.

      Returns:
      new total shift in seconds
      See Also:
      getPreviousOffset(), getRawOffset(), getExtraOffset(), ZonalOffset.getIntegralAmount()
    • getRawOffset

      public int getRawOffset()

      Returns the raw shift after this transition as difference between total shift and an extra shift (often daylight savings).

      Negative raw shifts are related to timezones west for Greenwich, positive to timezones east for Greenwich. The addition of the raw shift to POSIX-time yields the standard local time typically corresponding to winter time.

      Some few countries define the legal standard time the other way round. For example, Ireland labels the summer time as standard time. Hence this class avoids the usage of the term "standard time", but prefers the term "raw offset".

      Returns:
      raw shift in seconds after transition
      Since:
      5.5
      See Also:
      getTotalOffset(), getExtraOffset()
    • getExtraOffset

      public int getExtraOffset()

      Returns typically the DST-shift (daylight savings) after this transition that is the shift normally induced by change to summer time.

      This offset defines a deviation from the raw offset. The only legitimate method to determine if a time zone is actually in daylight saving mode is the method Timezone.isDaylightSaving(moment).

      Returns:
      extra shift in seconds after transition, can also be negative
      Since:
      5.5
      See Also:
      getTotalOffset(), getRawOffset()
    • getSize

      public int getSize()

      Gets the difference between new and old total shift as measure for the size of this transition.

      Returns:
      change of total shift in seconds (negative in case of overlap)
    • isGap

      public boolean isGap()

      Queries if this transition represents a gap on the local timeline where local timestamps are invalid.

      Returns:
      true if this transition represents a gap (by definition the new total shift is bigger than the previous one) else false
    • isOverlap

      public boolean isOverlap()

      Queries if this transition represents an overlap on the local timeline where local timestamps are ambivalent.

      Returns:
      true if this transition represents an overlap (by definition the new total shift is smaller than the previous one) else false
    • compareTo

      public int compareTo(ZonalTransition other)

      Compares preferrably the timeline order based on the global timestamps of transitions, otherwise the total shift and finally the extra shift.

      The natural order is consistent with equals().

      Specified by:
      compareTo in interface Comparable<ZonalTransition>
    • equals

      public boolean equals(Object obj)

      Based on the whole state with global POSIX-timestamp and all internal shifts.

      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()

      Based on the POSIX-timestamp of the transition.

      Overrides:
      hashCode in class Object
    • toString

      public String toString()

      Supports debugging.

      Overrides:
      toString in class Object
      Returns:
      String
    • getStandardOffset

      @Deprecated public int getStandardOffset()
      Deprecated.
      method was renamed and is subject to removal in future versions

      Synonym for getRawOffset().

      Returns:
      raw shift in seconds after transition
      See Also:
      getRawOffset()
    • getDaylightSavingOffset

      @Deprecated public int getDaylightSavingOffset()
      Deprecated.
      method was renamed and is subject to removal in future versions

      Synonym for getExtraOffset().

      Returns:
      daylight-saving-shift in seconds after transition, can also be negative
      See Also:
      getExtraOffset()