Jdk8Methods.requireNonNull(until, "until"); Jdk8Methods.requireNonNull(untilDefinition, "untilDefinition"); TZWindow window = new TZWindow(standardOffset, until, untilDefinition); if (windowList.size() > 0) { TZWindow previous = windowList.get(windowList.size() - 1); window.validateWindowOrder(previous);
addRule(lastRule.year, maxLastRuleStartYear, lastRule.month, lastRule.dayOfMonthIndicator, lastRule.dayOfWeek, lastRule.time, lastRule.adjustDays, lastRule.timeDefinition, lastRule.savingAmountSecs); lastRule.year = maxLastRuleStartYear + 1; addRule(lastRule.year, endYear + 1, lastRule.month, lastRule.dayOfMonthIndicator, lastRule.dayOfWeek, lastRule.time, lastRule.adjustDays, lastRule.timeDefinition, lastRule.savingAmountSecs);
/** * Sets the previously added window to have fixed savings. * <p> * Setting a window to have fixed savings simply means that a single daylight * savings amount applies throughout the window. The window could be small, * such as a single summer, or large, such as a multi-year daylight savings. * <p> * A window can either have fixed savings or rules but not both. * * @param fixedSavingAmountSecs the amount of saving to use for the whole window, not null * @return this, for chaining * @throws IllegalStateException if no window has yet been added * @throws IllegalStateException if the window already has rules */ public ZoneRulesBuilder setFixedSavingsToWindow(int fixedSavingAmountSecs) { if (windowList.isEmpty()) { throw new IllegalStateException("Must add a window before setting the fixed savings"); } TZWindow window = windowList.get(windowList.size() - 1); window.setFixedSavings(fixedSavingAmountSecs); return this; }
window.tidy(loopWindowStart.getYear()); ZoneOffsetTransition trans = deduplicate(rule.toTransition(loopStandardOffset, loopSavings)); if (trans.toEpochSecond() < loopWindowStart.toEpochSecond(loopWindowOffset) == false && trans.toEpochSecond() < window.createDateTimeEpochSecond(loopSavings) && trans.getOffsetBefore().equals(trans.getOffsetAfter()) == false) { transitionList.add(trans); loopWindowOffset = deduplicate(window.createWallOffset(loopSavings)); loopWindowStart = deduplicate(LocalDateTime.ofEpochSecond( window.createDateTimeEpochSecond(loopSavings), 0, loopWindowOffset));
window.tidy(loopWindowStart.getYear()); ZoneOffsetTransition trans = deduplicate(rule.toTransition(loopStandardOffset, loopSavings)); if (trans.toEpochSecond() < loopWindowStart.toEpochSecond(loopWindowOffset) == false && trans.toEpochSecond() < window.createDateTimeEpochSecond(loopSavings) && trans.getOffsetBefore().equals(trans.getOffsetAfter()) == false) { transitionList.add(trans); loopWindowOffset = deduplicate(window.createWallOffset(loopSavings)); loopWindowStart = deduplicate(LocalDateTime.ofEpochSecond( window.createDateTimeEpochSecond(loopSavings), 0, loopWindowOffset));
addRule(lastRule.year, maxLastRuleStartYear, lastRule.month, lastRule.dayOfMonthIndicator, lastRule.dayOfWeek, lastRule.time, lastRule.adjustDays, lastRule.timeDefinition, lastRule.savingAmountSecs); lastRule.year = maxLastRuleStartYear + 1; addRule(lastRule.year, endYear + 1, lastRule.month, lastRule.dayOfMonthIndicator, lastRule.dayOfWeek, lastRule.time, lastRule.adjustDays, lastRule.timeDefinition, lastRule.savingAmountSecs);
Jdk8Methods.requireNonNull(until, "until"); Jdk8Methods.requireNonNull(untilDefinition, "untilDefinition"); TZWindow window = new TZWindow(standardOffset, until, untilDefinition); if (windowList.size() > 0) { TZWindow previous = windowList.get(windowList.size() - 1); window.validateWindowOrder(previous);
/** * Sets the previously added window to have fixed savings. * <p> * Setting a window to have fixed savings simply means that a single daylight * savings amount applies throughout the window. The window could be small, * such as a single summer, or large, such as a multi-year daylight savings. * <p> * A window can either have fixed savings or rules but not both. * * @param fixedSavingAmountSecs the amount of saving to use for the whole window, not null * @return this, for chaining * @throws IllegalStateException if no window has yet been added * @throws IllegalStateException if the window already has rules */ public ZoneRulesBuilder setFixedSavingsToWindow(int fixedSavingAmountSecs) { if (windowList.isEmpty()) { throw new IllegalStateException("Must add a window before setting the fixed savings"); } TZWindow window = windowList.get(windowList.size() - 1); window.setFixedSavings(fixedSavingAmountSecs); return this; }
/** * Creates the offset date-time for the local date-time at the end of the window. * * @param savingsSecs the amount of savings in use in seconds * @return the created date-time epoch second in the wall offset, not null */ long createDateTimeEpochSecond(int savingsSecs) { ZoneOffset wallOffset = createWallOffset(savingsSecs); LocalDateTime ldt = timeDefinition.createDateTime(windowEnd, standardOffset, wallOffset); return ldt.toEpochSecond(wallOffset); } }
/** * Creates the offset date-time for the local date-time at the end of the window. * * @param savingsSecs the amount of savings in use in seconds * @return the created date-time epoch second in the wall offset, not null */ long createDateTimeEpochSecond(int savingsSecs) { ZoneOffset wallOffset = createWallOffset(savingsSecs); LocalDateTime ldt = timeDefinition.createDateTime(windowEnd, standardOffset, wallOffset); return ldt.toEpochSecond(wallOffset); } }