Class ZonalTransition
- All Implemented Interfaces:
Serializable
,Comparable<ZonalTransition>
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
ConstructorDescriptionZonalTransition(long posixTime, int previousOffset, int totalOffset, int extraOffset)
Creates a new transition between two shifts. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo(ZonalTransition other)
Compares preferrably the timeline order based on the global timestamps of transitions, otherwise the total shift and finally the extra shift.boolean
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 versionsint
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
getSize()
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 versionsint
Returns the total shift after this transition.int
hashCode()
Based on the POSIX-timestamp of the transition.boolean
isGap()
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.toString()
Supports debugging.
-
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 transitionpreviousOffset
- previous total shift in secondstotalOffset
- new total shift in secondsextraOffset
- 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) elsefalse
-
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) elsefalse
-
compareTo
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 interfaceComparable<ZonalTransition>
-
equals
Based on the whole state with global POSIX-timestamp and all internal shifts.
-
hashCode
public int hashCode()Based on the POSIX-timestamp of the transition.
-
toString
Supports debugging.
-
getStandardOffset
Deprecated.method was renamed and is subject to removal in future versionsSynonym for
getRawOffset()
.- Returns:
- raw shift in seconds after transition
- See Also:
getRawOffset()
-
getDaylightSavingOffset
Deprecated.method was renamed and is subject to removal in future versionsSynonym for
getExtraOffset()
.- Returns:
- daylight-saving-shift in seconds after transition, can also be negative
- See Also:
getExtraOffset()
-