Class ZoneRules

java.lang.Object
dev.gmitch215.bytebox.time.ZoneRules

public abstract class ZoneRules extends Object
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 Details

    • ZoneRules

      protected ZoneRules()
      For IntlZoneRules and the fixed rules below, and nothing else.
  • Method Details

    • of

      public static ZoneRules of(ZoneOffset offset)
      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 starts
      baseWallOffset - the wall offset before the history starts
      standardOffsetTransitionList - changes to the standard offset
      transitionList - the transitions
      lastRules - 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

      public abstract ZoneOffset getOffset(Instant instant)
      The offset at an instant.
      Parameters:
      instant - the instant
      Returns:
      the offset
    • getOffset

      public abstract ZoneOffset 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.
      Parameters:
      localDateTime - the reading
      Returns:
      the offset
    • getValidOffsets

      public abstract List<ZoneOffset> getValidOffsets(LocalDateTime localDateTime)
      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

      public abstract ZoneOffsetTransition getTransition(LocalDateTime localDateTime)
      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

      public abstract ZoneOffset getStandardOffset(Instant instant)
      The offset the zone keeps when daylight saving is not in force.
      Parameters:
      instant - the instant
      Returns:
      the offset
    • getDaylightSavings

      public abstract Duration getDaylightSavings(Instant instant)
      How far daylight saving has moved the clock.
      Parameters:
      instant - the instant
      Returns:
      the amount, zero when it is not in force
    • isDaylightSavings

      public abstract boolean isDaylightSavings(Instant instant)
      Whether daylight saving is in force.
      Parameters:
      instant - the instant
      Returns:
      whether it is
    • isValidOffset

      public abstract boolean isValidOffset(LocalDateTime localDateTime, ZoneOffset offset)
      Whether a wall-clock reading and an offset go together.
      Parameters:
      localDateTime - the reading
      offset - the offset
      Returns:
      whether they do
    • nextTransition

      public abstract ZoneOffsetTransition nextTransition(Instant instant)
      The next change after an instant.
      Parameters:
      instant - the instant
      Returns:
      the change, or null when none is scheduled
    • previousTransition

      public abstract ZoneOffsetTransition previousTransition(Instant instant)
      The last change before an instant.
      Parameters:
      instant - the instant
      Returns:
      the change, or null when there was none
    • getTransitions

      public abstract List<ZoneOffsetTransition> getTransitions()
      Returns every recorded change.
      Returns:
      every recorded change
    • getTransitionRules

      public abstract List<ZoneOffsetTransitionRule> getTransitionRules()
      Returns the rules by which changes recur.
      Returns:
      the rules by which changes recur
    • equals

      public abstract boolean equals(Object otherRules)
      Overrides:
      equals in class Object
    • hashCode

      public abstract int hashCode()
      Overrides:
      hashCode in class Object