// check if using last rules
if (epochSecs >= savingsInstantTransitions[savingsInstantTransitions.length - 1]) {
if (lastRules.length == 0) {
return null;
}
OffsetDateTime dt = OffsetDateTime.fromInstant(instant, wallOffsets[wallOffsets.length - 1]);
for (Year year = dt.toYear(); true; year = year.next()) {
ZoneOffsetTransition[] transArray = findTransitionArray(year);
for (ZoneOffsetTransition trans : transArray) {
if (instant.isBefore(trans.getInstant())) {
return trans;
}
}
if (year.getValue() == Year.MAX_YEAR) {
return null;
}
}
}
// using historic rules
int index = Arrays.binarySearch(savingsInstantTransitions, epochSecs);
if (index < 0) {
index = -index - 1; // switched value is the next transition
} else {
index += 1; // exact match, so need to add one to get the next
}
Instant transitionInstant = Instant.seconds(savingsInstantTransitions[index]);
OffsetDateTime trans = OffsetDateTime.fromInstant(transitionInstant, wallOffsets[index]);
return createTransition(trans, wallOffsets[index + 1]);
}