Class ZoneRules
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.
Final, and a zone is carried in a field rather than in a subclass. A subclass would have to name
this class as its supertype, which is the one name a substitute may not use: the compiler
translates java.time.zone.ZoneRules into a copy of this class under the original name,
while a subclass goes on extending this one, and the two are unrelated wasm types. The symptom is
a CompileError from the engine naming a method that returns one where the other is
declared, so javac refusing the subclass is the cheaper failure.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleangetDaylightSavings(Instant instant) How far daylight saving has moved the clock.The offset at an instant.getOffset(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.getStandardOffset(Instant instant) The offset the zone keeps when daylight saving is not in force.getTransition(LocalDateTime localDateTime) The change a wall-clock reading falls inside.Returns the rules by which changes recur.Returns every recorded change.getValidOffsets(LocalDateTime localDateTime) Every offset a wall-clock reading could mean: none in a gap, two in an overlap, otherwise one.inthashCode()booleanisDaylightSavings(Instant instant) Whether daylight saving is in force.booleanReturns whether the offset never varies.booleanisValidOffset(LocalDateTime localDateTime, ZoneOffset offset) Whether a wall-clock reading and an offset go together.nextTransition(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.previousTransition(Instant instant) The last change before an instant.toString()
-
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 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 int hashCode() -
toString
-