Package javax.time.calendar.zone
Class ZoneRulesBuilder.TZWindow
java.lang.Object
javax.time.calendar.zone.ZoneRulesBuilder.TZWindow
- Enclosing class:
- ZoneRulesBuilder
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 Summary
FieldsModifier and TypeFieldDescriptionprivate Period
The fixed amount of the saving to be applied during this window.private List<ZoneRulesBuilder.TZRule>
The last rules.private int
The latest year that the last year starts at.private List<ZoneRulesBuilder.TZRule>
The rules for the current window.private final ZoneOffset
The standard offset during the window, not null.private final ZoneRulesBuilder.TimeDefinition
The type of the end time, not null.private final LocalDateTime
The end local time, not null. -
Constructor Summary
ConstructorsConstructorDescriptionTZWindow
(ZoneOffset standardOffset, LocalDateTime windowEnd, ZoneRulesBuilder.TimeDefinition timeDefinition) Constructor. -
Method Summary
Modifier and TypeMethodDescription(package private) void
addRule
(int startYear, int endYear, MonthOfYear month, int dayOfMonthIndicator, DayOfWeek dayOfWeek, LocalTime time, boolean timeEndOfDay, ZoneRulesBuilder.TimeDefinition timeDefinition, Period savingAmount) Adds a rule to the current window.(package private) OffsetDateTime
createDateTime
(Period savings) Creates the offset date-time for the local date-time at the end of the window.(package private) boolean
Checks if the window is empty.(package private) void
setFixedSavings
(Period fixedSavingAmount) Sets the fixed savings amount for the window.(package private) void
tidy
(int windowStartYear) Adds rules to make the last rules all start from the same year.(package private) void
validateWindowOrder
(ZoneRulesBuilder.TZWindow previous) Validates that this window is after the previous one.
-
Field Details
-
standardOffset
The standard offset during the window, not null. -
windowEnd
The end local time, not null. -
timeDefinition
The type of the end time, not null. -
fixedSavingAmount
The fixed amount of the saving to be applied during this window. -
ruleList
The rules for the current window. -
maxLastRuleStartYear
private int maxLastRuleStartYearThe latest year that the last year starts at. -
lastRuleList
The last rules.
-
-
Constructor Details
-
TZWindow
TZWindow(ZoneOffset standardOffset, LocalDateTime windowEnd, ZoneRulesBuilder.TimeDefinition timeDefinition) Constructor.- Parameters:
standardOffset
- the standard offset applicable during the window, not nullwindowEnd
- the end of the window, relative to the time definition, null if forevertimeDefinition
- the time definition for calculating the true end, not null
-
-
Method Details
-
setFixedSavings
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, MonthOfYear month, int dayOfMonthIndicator, DayOfWeek dayOfWeek, LocalTime time, boolean timeEndOfDay, ZoneRulesBuilder.TimeDefinition timeDefinition, Period savingAmount) Adds a rule to the current window.- Parameters:
startYear
- the start year of the rule, from MIN_YEAR to MAX_YEARendYear
- the end year of the rule, from MIN_YEAR to MAX_YEARmonth
- the month of the transition, not nulldayOfMonthIndicator
- 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 monthdayOfWeek
- the day-of-week to adjust to, null if day-of-month should not be adjustedtime
- the time that the transition occurs as defined by timeDefintion, not nulltimeEndOfDay
- whether midnight is at the end of daytimeDefinition
- the definition of how to convert local to actual time, not nullsavingAmount
- the amount of saving from the standard offset, not null- Throws:
IllegalStateException
- if the window already has fixed savingsIllegalStateException
- if the window has reached the maximum capacity of 2000 rules
-
validateWindowOrder
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
-
createDateTime
Creates the offset date-time for the local date-time at the end of the window.- Parameters:
savings
- the amount of savings in use, not null- Returns:
- the created offset date-time in the wall offset, never null
-