Class FixedZoneRules
- java.lang.Object
-
- javax.time.calendar.zone.ZoneRules
-
- javax.time.calendar.zone.FixedZoneRules
-
- All Implemented Interfaces:
java.io.Serializable
final class FixedZoneRules extends ZoneRules implements java.io.Serializable
Implementation of zone rules for fixed offsets.
-
-
Field Summary
Fields Modifier and Type Field Description private ZoneOffsetoffsetThe fixed offset.private static longserialVersionUIDA serialization identifier for this class.
-
Constructor Summary
Constructors Constructor Description FixedZoneRules(ZoneOffset offset)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object otherRules)Checks if this object equals another, comparing the offset.ZoneOffsetgetOffset(InstantProvider instant)Gets the offset applicable at the specified instant in this zone.ZoneOffsetInfogetOffsetInfo(LocalDateTime dateTime)Gets the offset information for a local date-time in this zone.ZoneOffsetgetStandardOffset(InstantProvider instant)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 fully defined transitions.inthashCode()Returns a suitable hash code.booleanisFixedOffset()Checks of the zone rules are fixed, such that the offset never varies.ZoneOffsetTransitionnextTransition(InstantProvider instantProvider)Gets the next transition after the specified transition.ZoneOffsetTransitionpreviousTransition(InstantProvider instantProvider)Gets the previous transition after the specified transition.(package private) static FixedZoneRulesreadExternal(java.io.DataInput in)Reads the state from the stream.java.lang.StringtoString()Returns a string describing this object.(package private) voidwriteExternal(java.io.DataOutput out)Writes the state to the stream.private java.lang.ObjectwriteReplace()Uses a serialization delegate.-
Methods inherited from class javax.time.calendar.zone.ZoneRules
checkNotNull, getDaylightSavings, getOffsetInfo, isDaylightSavings, isValidDateTime, ofFixed
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
A serialization identifier for this class.- See Also:
- Constant Field Values
-
offset
private final ZoneOffset offset
The fixed offset.
-
-
Constructor Detail
-
FixedZoneRules
FixedZoneRules(ZoneOffset offset)
Constructor.- Parameters:
offset- the zone offset, 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.IOExceptionWrites the state to the stream.- Parameters:
out- the output stream, not null- Throws:
java.io.IOException- if an error occurs
-
readExternal
static FixedZoneRules readExternal(java.io.DataInput in) throws java.io.IOException
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 occurs
-
getOffset
public ZoneOffset getOffset(InstantProvider instant)
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 dateTime)
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:
getOffsetInfoin classZoneRules- Parameters:
dateTime- the date-time to find the offset information for, not null- Returns:
- the offset information, never null
-
getStandardOffset
public ZoneOffset getStandardOffset(InstantProvider instant)
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:
getStandardOffsetin classZoneRules- Parameters:
instant- the instant to find the offset information for, not null- Returns:
- the standard offset, never null
-
isFixedOffset
public boolean isFixedOffset()
Checks of the zone rules are fixed, such that the offset never varies.It is intended that
OffsetDateTime,OffsetDateandOffsetTimeare used in preference to fixed offset time-zones inZonedDateTime.The default implementation returns false.
- Overrides:
isFixedOffsetin classZoneRules- Returns:
- true if the time-zone is fixed and the offset never changes
-
nextTransition
public ZoneOffsetTransition nextTransition(InstantProvider instantProvider)
Gets the next transition after the specified transition.This returns details of the next transition after the specified instant.
Some providers of rules may not be able to return this information, thus the method is defined to throw UnsupportedOperationException. The supplied rules implementations do supply this information and don't throw the exception
- Specified by:
nextTransitionin 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.This returns details of the previous transition after the specified instant.
Some providers of rules may not be able to return this information, thus the method is defined to throw UnsupportedOperationException. The supplied rules implementations do supply this information and don't throw the exception
- Specified by:
previousTransitionin 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 fully defined transitions.The complete set of transitions for this rules instance is defined by this method and
ZoneRules.getTransitionRules(). This method returns those transitions that have been fully defined. These are typically historical, but may be in the future. The list will be empty for fixed offset rules.Some providers of rules cannot return this information, thus this method is defined to throw UnsupportedOperationException. The supplied 'TZDB' implementation can supply this information thus does not throw the exception.
- Specified by:
getTransitionsin classZoneRules- Returns:
- independent, modifiable copy of the list of fully defined 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 complete set of transitions for this rules instance is defined by this method and
ZoneRules.getTransitions(). This method returns instances ofZoneOffsetTransitionRulethat define an algorithm for when transitions will occur. The list will be empty for fixed offset rules.For any given
ZoneRules, this list contains the transition rules for years beyond those years that have been fully defined. These rules typically refer to future daylight savings time rule changes.If the zone defines daylight savings into the future, then the list will normally be of size two and hold information about entering and exiting daylight savings. If the zone does not have daylight savings, or information about future changes is uncertain, then the list will be empty.
Some providers of rules cannot return this information, thus this method is defined to throw UnsupportedOperationException. The supplied 'TZDB' implementation can supply this information thus does not throw the exception.
- Specified by:
getTransitionRulesin 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 offset.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:
toStringin classjava.lang.Object- Returns:
- a string for debugging, never null
-
-