mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8263668: Update java.time to use instanceof pattern variable
Reviewed-by: lancea, ryadav, naoto, rriggs, dfuchs, scolebourne, chegar
This commit is contained in:
parent
a93d911954
commit
28af31db34
34 changed files with 129 additions and 176 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue