8263668: Update java.time to use instanceof pattern variable

Reviewed-by: lancea, ryadav, naoto, rriggs, dfuchs, scolebourne, chegar
This commit is contained in:
Patrick Concannon 2021-04-22 10:17:43 +00:00
parent a93d911954
commit 28af31db34
34 changed files with 129 additions and 176 deletions

View file

@ -373,10 +373,10 @@ final class ChronoLocalDateTimeImpl<D extends ChronoLocalDate>
Objects.requireNonNull(endExclusive, "endExclusive");
@SuppressWarnings("unchecked")
ChronoLocalDateTime<D> end = (ChronoLocalDateTime<D>) getChronology().localDateTime(endExclusive);
if (unit instanceof ChronoUnit) {
if (unit instanceof ChronoUnit chronoUnit) {
if (unit.isTimeBased()) {
long amount = end.getLong(EPOCH_DAY) - date.getLong(EPOCH_DAY);
switch ((ChronoUnit) unit) {
switch (chronoUnit) {
case NANOS: amount = Math.multiplyExact(amount, NANOS_PER_DAY); break;
case MICROS: amount = Math.multiplyExact(amount, MICROS_PER_DAY); break;
case MILLIS: amount = Math.multiplyExact(amount, MILLIS_PER_DAY); break;