/** * Converts this to a transition. * * @param standardOffset the active standard offset, not null * @param savingsBeforeSecs the active savings in seconds * @return the transition, not null */ ZoneOffsetTransition toTransition(ZoneOffset standardOffset, int savingsBeforeSecs) { // copy of code in ZoneOffsetTransitionRule to avoid infinite loop LocalDate date = toLocalDate(); date = deduplicate(date); LocalDateTime ldt = deduplicate(LocalDateTime.of(date.plusDays(adjustDays), time)); ZoneOffset wallOffset = deduplicate(ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingsBeforeSecs)); LocalDateTime dt = deduplicate(timeDefinition.createDateTime(ldt, standardOffset, wallOffset)); ZoneOffset offsetAfter = deduplicate(ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingAmountSecs)); return new ZoneOffsetTransition(dt, wallOffset, offsetAfter); }
/** * Converts this to a transition. * * @param standardOffset the active standard offset, not null * @param savingsBeforeSecs the active savings in seconds * @return the transition, not null */ ZoneOffsetTransition toTransition(ZoneOffset standardOffset, int savingsBeforeSecs) { // copy of code in ZoneOffsetTransitionRule to avoid infinite loop LocalDate date = toLocalDate(); date = deduplicate(date); LocalDateTime ldt = deduplicate(LocalDateTime.of(date.plusDays(adjustDays), time)); ZoneOffset wallOffset = deduplicate(ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingsBeforeSecs)); LocalDateTime dt = deduplicate(timeDefinition.createDateTime(ldt, standardOffset, wallOffset)); ZoneOffset offsetAfter = deduplicate(ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingAmountSecs)); return new ZoneOffsetTransition(dt, wallOffset, offsetAfter); }
public int compareTo(TZRule other) { int cmp = year - other.year; cmp = (cmp == 0 ? month.compareTo(other.month) : cmp); if (cmp == 0) { // convert to date to handle dow/domIndicator/timeEndOfDay LocalDate thisDate = toLocalDate(); LocalDate otherDate = other.toLocalDate(); cmp = thisDate.compareTo(otherDate); } if (cmp != 0) { return cmp; } long timeSecs1 = time.toSecondOfDay() + adjustDays * 86400; long timeSecs2 = other.time.toSecondOfDay() + other.adjustDays * 86400; return timeSecs1 < timeSecs2 ? -1 : (timeSecs1 > timeSecs2 ? 1 : 0); }
public int compareTo(TZRule other) { int cmp = year - other.year; cmp = (cmp == 0 ? month.compareTo(other.month) : cmp); if (cmp == 0) { // convert to date to handle dow/domIndicator/timeEndOfDay LocalDate thisDate = toLocalDate(); LocalDate otherDate = other.toLocalDate(); cmp = thisDate.compareTo(otherDate); } if (cmp != 0) { return cmp; } long timeSecs1 = time.toSecondOfDay() + adjustDays * 86400; long timeSecs2 = other.time.toSecondOfDay() + other.adjustDays * 86400; return timeSecs1 < timeSecs2 ? -1 : (timeSecs1 > timeSecs2 ? 1 : 0); }