Class ZoneRulesBuilder.TZWindow

java.lang.Object
org.threeten.bp.zone.ZoneRulesBuilder.TZWindow
Enclosing class:
ZoneRulesBuilder

class ZoneRulesBuilder.TZWindow extends Object
A definition of a window in the time-line. The window will have one standard offset and will either have a fixed DST savings or a set of rules.
  • Field Details

    • standardOffset

      private final ZoneOffset standardOffset
      The standard offset during the window, not null.
    • windowEnd

      private final LocalDateTime windowEnd
      The end local time, not null.
    • timeDefinition

      private final ZoneOffsetTransitionRule.TimeDefinition timeDefinition
      The type of the end time, not null.
    • fixedSavingAmountSecs

      private Integer fixedSavingAmountSecs
      The fixed amount of the saving to be applied during this window.
    • ruleList

      private List<ZoneRulesBuilder.TZRule> ruleList
      The rules for the current window.
    • maxLastRuleStartYear

      private int maxLastRuleStartYear
      The latest year that the last year starts at.
    • lastRuleList

      private List<ZoneRulesBuilder.TZRule> lastRuleList
      The last rules.
  • Constructor Details

    • TZWindow

      TZWindow(ZoneOffset standardOffset, LocalDateTime windowEnd, ZoneOffsetTransitionRule.TimeDefinition timeDefinition)
      Constructor.
      Parameters:
      standardOffset - the standard offset applicable during the window, not null
      windowEnd - the end of the window, relative to the time definition, null if forever
      timeDefinition - the time definition for calculating the true end, not null
  • Method Details

    • setFixedSavings

      void setFixedSavings(int fixedSavingAmount)
      Sets the fixed savings amount for the window.
      Parameters:
      fixedSavingAmount - the amount of daylight saving to apply throughout the window, may be null
      Throws:
      IllegalStateException - if the window already has rules
    • addRule

      void addRule(int startYear, int endYear, Month month, int dayOfMonthIndicator, DayOfWeek dayOfWeek, LocalTime time, int adjustDays, ZoneOffsetTransitionRule.TimeDefinition timeDefinition, int savingAmountSecs)
      Adds a rule to the current window.
      Parameters:
      startYear - the start year of the rule, from MIN_VALUE to MAX_VALUE
      endYear - the end year of the rule, from MIN_VALUE to MAX_VALUE
      month - the month of the transition, not null
      dayOfMonthIndicator - the day-of-month of the transition, adjusted by dayOfWeek, from 1 to 31 adjusted later, or -1 to -28 adjusted earlier from the last day of the month
      dayOfWeek - the day-of-week to adjust to, null if day-of-month should not be adjusted
      time - the time that the transition occurs as defined by timeDefintion, not null
      adjustDays - the time days adjustment
      timeDefinition - the definition of how to convert local to actual time, not null
      savingAmountSecs - the amount of saving from the standard offset in seconds
      Throws:
      IllegalStateException - if the window already has fixed savings
      IllegalStateException - if the window has reached the maximum capacity of 2000 rules
    • validateWindowOrder

      void validateWindowOrder(ZoneRulesBuilder.TZWindow previous)
      Validates that this window is after the previous one.
      Parameters:
      previous - the previous window, not null
      Throws:
      IllegalStateException - if the window order is invalid
    • tidy

      void tidy(int windowStartYear)
      Adds rules to make the last rules all start from the same year. Also add one more year to avoid weird case where penultimate year has odd offset.
      Parameters:
      windowStartYear - the window start year
      Throws:
      IllegalStateException - if there is only one rule defined as being forever
    • isSingleWindowStandardOffset

      boolean isSingleWindowStandardOffset()
      Checks if the window is empty.
      Returns:
      true if the window is only a standard offset
    • createWallOffset

      ZoneOffset createWallOffset(int savingsSecs)
      Creates the wall offset for the local date-time at the end of the window.
      Parameters:
      savingsSecs - the amount of savings in use in seconds
      Returns:
      the created date-time epoch second in the wall offset, not null
    • createDateTimeEpochSecond

      long createDateTimeEpochSecond(int savingsSecs)
      Creates the offset date-time for the local date-time at the end of the window.
      Parameters:
      savingsSecs - the amount of savings in use in seconds
      Returns:
      the created date-time epoch second in the wall offset, not null