Class StandardZoneRules
- java.lang.Object
-
- javax.time.calendar.zone.ZoneRules
-
- javax.time.calendar.zone.StandardZoneRules
-
- All Implemented Interfaces:
java.io.Serializable
final class StandardZoneRules extends ZoneRules implements java.io.Serializable
The rules describing how the zone offset varies through the year and historically.ZoneRules is immutable and thread-safe.
-
-
Field Summary
Fields Modifier and Type Field Description private static int
LAST_CACHED_YEAR
The last year to have its transitions cached.private ZoneOffsetTransitionRule[]
lastRules
The last rule.private java.util.concurrent.ConcurrentMap<Year,ZoneOffsetTransition[]>
lastRulesCache
The map of recent transitions.private long[]
savingsInstantTransitions
The transitions between instants (epoch seconds), sorted.private LocalDateTime[]
savingsLocalTransitions
The transitions between local date-times, sorted.private static long
serialVersionUID
A serialization identifier for this class.private ZoneOffset[]
standardOffsets
The standard offsets.private long[]
standardTransitions
The transitions between standard offsets (epoch seconds), sorted.private ZoneOffset[]
wallOffsets
The wall offsets.
-
Constructor Summary
Constructors Modifier Constructor Description private
StandardZoneRules(long[] standardTransitions, ZoneOffset[] standardOffsets, long[] savingsInstantTransitions, ZoneOffset[] wallOffsets, ZoneOffsetTransitionRule[] lastRules)
Constructor.(package private)
StandardZoneRules(ZoneOffset baseStandardOffset, ZoneOffset baseWallOffset, java.util.List<OffsetDateTime> standardOffsetTransitionList, java.util.List<ZoneOffsetTransition> transitionList, java.util.List<ZoneOffsetTransitionRule> lastRules)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object otherRules)
Checks if this object equals another, comparing the complete set of rules.private ZoneOffsetInfo
findOffsetInfo(LocalDateTime dt, ZoneOffsetTransition trans)
Finds the offset info for a local date-time and transition.private ZoneOffsetTransition[]
findTransitionArray(int year)
Finds the appropriate transition array for the given year.ZoneOffset
getOffset(InstantProvider instantProvider)
Gets the offset applicable at the specified instant in this zone.ZoneOffsetInfo
getOffsetInfo(LocalDateTime dt)
Gets the offset information for a local date-time in this zone.ZoneOffset
getStandardOffset(InstantProvider instantProvider)
Gets the standard offset for the specified instant in this zone.java.util.List<ZoneOffsetTransitionRule>
getTransitionRules()
Gets the list of transition rules for years beyond those defined in the transition list.java.util.List<ZoneOffsetTransition>
getTransitions()
Gets the complete list of transitions.int
hashCode()
Returns a suitable hash code.ZoneOffsetTransition
nextTransition(InstantProvider instantProvider)
Gets the next transition after the specified transition.ZoneOffsetTransition
previousTransition(InstantProvider instantProvider)
Gets the previous transition after the specified transition.(package private) static StandardZoneRules
readExternal(java.io.DataInput in)
Reads the state from the stream.java.lang.String
toString()
Returns a string describing this object.(package private) void
writeExternal(java.io.DataOutput out)
Writes the state to the stream.private java.lang.Object
writeReplace()
Uses a serialization delegate.-
Methods inherited from class javax.time.calendar.zone.ZoneRules
checkNotNull, getDaylightSavings, getOffsetInfo, isDaylightSavings, isFixedOffset, isValidDateTime, ofFixed
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
A serialization identifier for this class.- See Also:
- Constant Field Values
-
LAST_CACHED_YEAR
private static final int LAST_CACHED_YEAR
The last year to have its transitions cached.- See Also:
- Constant Field Values
-
standardTransitions
private final long[] standardTransitions
The transitions between standard offsets (epoch seconds), sorted.
-
standardOffsets
private final ZoneOffset[] standardOffsets
The standard offsets.
-
savingsInstantTransitions
private final long[] savingsInstantTransitions
The transitions between instants (epoch seconds), sorted.
-
savingsLocalTransitions
private final LocalDateTime[] savingsLocalTransitions
The transitions between local date-times, sorted. This is a paired array, where the first entry is the start of the transition and the second entry is the end of the transition.
-
wallOffsets
private final ZoneOffset[] wallOffsets
The wall offsets.
-
lastRules
private final ZoneOffsetTransitionRule[] lastRules
The last rule.
-
lastRulesCache
private final java.util.concurrent.ConcurrentMap<Year,ZoneOffsetTransition[]> lastRulesCache
The map of recent transitions.
-
-
Constructor Detail
-
StandardZoneRules
StandardZoneRules(ZoneOffset baseStandardOffset, ZoneOffset baseWallOffset, java.util.List<OffsetDateTime> standardOffsetTransitionList, java.util.List<ZoneOffsetTransition> transitionList, java.util.List<ZoneOffsetTransitionRule> lastRules)
Constructor.- Parameters:
baseStandardOffset
- the standard offset to use before legal rules were set, not nullbaseWallOffset
- the wall offset to use before legal rules were set, not nullstandardOffsetTransitionList
- the list of changes to the standard offset, not nulltransitionList
- the list of transitions, not nulllastRules
- the recurring last rules, size 15 or less, not null
-
StandardZoneRules
private StandardZoneRules(long[] standardTransitions, ZoneOffset[] standardOffsets, long[] savingsInstantTransitions, ZoneOffset[] wallOffsets, ZoneOffsetTransitionRule[] lastRules)
Constructor.- Parameters:
standardTransitions
- the standard transitions, not nullstandardOffsets
- the standard offsets, not nullsavingsLocalTransitions
- the standard transitions, not nullwallOffsets
- the wall offsets, not nulllastRules
- the recurring last rules, size 15 or less, not null
-
-
Method Detail
-
writeReplace
private java.lang.Object writeReplace()
Uses a serialization delegate.- Returns:
- the replacing object, never null
-
writeExternal
void writeExternal(java.io.DataOutput out) throws java.io.IOException
Writes the state to the stream.- Parameters:
out
- the output stream, not null- Throws:
java.io.IOException
- if an error occurs
-
readExternal
static StandardZoneRules readExternal(java.io.DataInput in) throws java.io.IOException, java.lang.ClassNotFoundException
Reads the state from the stream.- Parameters:
in
- the input stream, not null- Returns:
- the created object, never null
- Throws:
java.io.IOException
- if an error occursjava.lang.ClassNotFoundException
-
getOffset
public ZoneOffset getOffset(InstantProvider instantProvider)
Gets the offset applicable at the specified instant in this zone.For any given instant there can only ever be one valid offset, which is returned by this method. To access more detailed information about the offset at and around the instant use
ZoneRules.getOffsetInfo(Instant)
.
-
getOffsetInfo
public ZoneOffsetInfo getOffsetInfo(LocalDateTime dt)
Gets the offset information for a local date-time in this zone.This provides access to full details as to the offset or offsets applicable for the local date-time. The mapping from a local date-time to an offset is not straightforward. There are three cases:
- Normal. Where there is a single offset for the local date-time.
- Gap. Where there is a gap in the local time-line normally caused by the spring cutover to daylight savings. There are no valid offsets within the gap
- Overlap. Where there is a gap in the local time-line normally caused by the autumn cutover from daylight savings. There are two valid offsets during the overlap.
ZoneOffsetInfo.isTransition()
to handle the gap or overlap.- Specified by:
getOffsetInfo
in classZoneRules
- Parameters:
dt
- the date-time to find the offset information for, not null- Returns:
- the offset information, never null
-
findOffsetInfo
private ZoneOffsetInfo findOffsetInfo(LocalDateTime dt, ZoneOffsetTransition trans)
Finds the offset info for a local date-time and transition.- Parameters:
dt
- the date-time, not nulltrans
- the transition, not null- Returns:
- the offset info, never null
-
findTransitionArray
private ZoneOffsetTransition[] findTransitionArray(int year)
Finds the appropriate transition array for the given year.- Parameters:
year
- the year, not null- Returns:
- the transition array, never null
-
getStandardOffset
public ZoneOffset getStandardOffset(InstantProvider instantProvider)
Gets the standard offset for the specified instant in this zone.This provides access to historic information on how the standard offset has changed over time. The standard offset is the offset before any daylight savings time is applied. This is typically the offset applicable during winter.
- Specified by:
getStandardOffset
in classZoneRules
- Parameters:
instantProvider
- the instant to find the offset information for, not null- Returns:
- the standard offset, never null
-
nextTransition
public ZoneOffsetTransition nextTransition(InstantProvider instantProvider)
Gets the next transition after the specified transition.- Specified by:
nextTransition
in classZoneRules
- Parameters:
instantProvider
- the instant to get the next transition after, not null- Returns:
- the next transition after the specified instant, null if this is after the last transition
-
previousTransition
public ZoneOffsetTransition previousTransition(InstantProvider instantProvider)
Gets the previous transition after the specified transition.- Specified by:
previousTransition
in classZoneRules
- Parameters:
instantProvider
- the instant to get the previous transition after, not null- Returns:
- the previous transition after the specified instant, null if this is before the first transition
-
getTransitions
public java.util.List<ZoneOffsetTransition> getTransitions()
Gets the complete list of transitions.This list normally contains a complete historical set of transitions that have occurred. Some transitions may be in the future, although generally the transition rules handle future years.
- Specified by:
getTransitions
in classZoneRules
- Returns:
- independent, modifiable copy of the list of transitions, never null
-
getTransitionRules
public java.util.List<ZoneOffsetTransitionRule> getTransitionRules()
Gets the list of transition rules for years beyond those defined in the transition list.The list represents all the transitions that are expected in each year beyond those in the transition list. Normally, there are two transitions per year - into and out of daylight savings time. If daylight savings time does not occur then the list will be empty.
- Specified by:
getTransitionRules
in classZoneRules
- Returns:
- independent, modifiable copy of the list of transition rules, never null
-
equals
public boolean equals(java.lang.Object otherRules)
Checks if this object equals another, comparing the complete set of rules.The entire state of the object is compared.
-
hashCode
public int hashCode()
Returns a suitable hash code.
-
toString
public java.lang.String toString()
Returns a string describing this object.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string for debugging, never null
-
-