Package dev.gmitch215.bytebox.time
Class ZoneRules
java.lang.Object
dev.gmitch215.bytebox.time.ZoneRules
What a zone's offset was, and when it changed.
This is java.time.zone.ZoneRules, and it is here rather than taken from the
implementation underneath because that one can only be subclassed from inside its own package, and
the rules on this platform come from IntlZoneRules rather than from a rule table. Replacing
it also leaves the table reader, the rule builder and the binary format unreachable.
of(ZoneOffset) builds the fixed rules a bare offset has, which is the case
ZoneOffset.getRules() needs. The five-argument form builds rules from a transition history
and refuses, because a history is what this platform does not have to give.
- Since:
- 1.0.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedForIntlZoneRulesand the fixed rules below, and nothing else. -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanabstract DurationgetDaylightSavings(Instant instant) How far daylight saving has moved the clock.abstract ZoneOffsetThe offset at an instant.abstract ZoneOffsetgetOffset(LocalDateTime localDateTime) The offset that applies to a wall-clock reading, preferring the earlier one where it happens twice and the one after the change where it does not happen at all.abstract ZoneOffsetgetStandardOffset(Instant instant) The offset the zone keeps when daylight saving is not in force.abstract ZoneOffsetTransitiongetTransition(LocalDateTime localDateTime) The change a wall-clock reading falls inside.abstract List<ZoneOffsetTransitionRule> Returns the rules by which changes recur.abstract List<ZoneOffsetTransition> Returns every recorded change.abstract List<ZoneOffset> getValidOffsets(LocalDateTime localDateTime) Every offset a wall-clock reading could mean: none in a gap, two in an overlap, otherwise one.abstract inthashCode()abstract booleanisDaylightSavings(Instant instant) Whether daylight saving is in force.abstract booleanReturns whether the offset never varies.abstract booleanisValidOffset(LocalDateTime localDateTime, ZoneOffset offset) Whether a wall-clock reading and an offset go together.abstract ZoneOffsetTransitionnextTransition(Instant instant) The next change after an instant.static ZoneRulesof(ZoneOffset offset) The rules of a zone that is only ever one offset.static ZoneRulesof(ZoneOffset baseStandardOffset, ZoneOffset baseWallOffset, List<ZoneOffsetTransition> standardOffsetTransitionList, List<ZoneOffsetTransition> transitionList, List<ZoneOffsetTransitionRule> lastRules) Rules assembled from a transition history, which is not available here.abstract ZoneOffsetTransitionpreviousTransition(Instant instant) The last change before an instant.
-
Constructor Details
-
ZoneRules
protected ZoneRules()ForIntlZoneRulesand the fixed rules below, and nothing else.
-
-
Method Details
-
of
The rules of a zone that is only ever one offset.- Parameters:
offset- the offset- Returns:
- rules that always answer with it
-
of
public static ZoneRules of(ZoneOffset baseStandardOffset, ZoneOffset baseWallOffset, List<ZoneOffsetTransition> standardOffsetTransitionList, List<ZoneOffsetTransition> transitionList, List<ZoneOffsetTransitionRule> lastRules) Rules assembled from a transition history, which is not available here.- Parameters:
baseStandardOffset- the standard offset before the history startsbaseWallOffset- the wall offset before the history startsstandardOffsetTransitionList- changes to the standard offsettransitionList- the transitionslastRules- the recurring rules- Returns:
- never
- Throws:
UnsupportedOperationException- always
-
isFixedOffset
public abstract boolean isFixedOffset()Returns whether the offset never varies.- Returns:
- whether the offset never varies
-
getOffset
The offset at an instant.- Parameters:
instant- the instant- Returns:
- the offset
-
getOffset
The offset that applies to a wall-clock reading, preferring the earlier one where it happens twice and the one after the change where it does not happen at all.- Parameters:
localDateTime- the reading- Returns:
- the offset
-
getValidOffsets
Every offset a wall-clock reading could mean: none in a gap, two in an overlap, otherwise one.- Parameters:
localDateTime- the reading- Returns:
- the offsets, earliest first
-
getTransition
The change a wall-clock reading falls inside.- Parameters:
localDateTime- the reading- Returns:
- the change, or null when the reading is an ordinary one
-
getStandardOffset
The offset the zone keeps when daylight saving is not in force.- Parameters:
instant- the instant- Returns:
- the offset
-
getDaylightSavings
How far daylight saving has moved the clock.- Parameters:
instant- the instant- Returns:
- the amount, zero when it is not in force
-
isDaylightSavings
Whether daylight saving is in force.- Parameters:
instant- the instant- Returns:
- whether it is
-
isValidOffset
Whether a wall-clock reading and an offset go together.- Parameters:
localDateTime- the readingoffset- the offset- Returns:
- whether they do
-
nextTransition
The next change after an instant.- Parameters:
instant- the instant- Returns:
- the change, or null when none is scheduled
-
previousTransition
The last change before an instant.- Parameters:
instant- the instant- Returns:
- the change, or null when there was none
-
getTransitions
Returns every recorded change.- Returns:
- every recorded change
-
getTransitionRules
Returns the rules by which changes recur.- Returns:
- the rules by which changes recur
-
equals
-
hashCode
public abstract int hashCode()
-