mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +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
|
@ -1683,7 +1683,7 @@ public final class LocalDateTime
|
|||
@Override
|
||||
public long until(Temporal endExclusive, TemporalUnit unit) {
|
||||
LocalDateTime end = LocalDateTime.from(endExclusive);
|
||||
if (unit instanceof ChronoUnit) {
|
||||
if (unit instanceof ChronoUnit chronoUnit) {
|
||||
if (unit.isTimeBased()) {
|
||||
long amount = date.daysUntil(end.date);
|
||||
if (amount == 0) {
|
||||
|
@ -1697,7 +1697,7 @@ public final class LocalDateTime
|
|||
amount++; // safe
|
||||
timePart -= NANOS_PER_DAY; // safe
|
||||
}
|
||||
switch ((ChronoUnit) unit) {
|
||||
switch (chronoUnit) {
|
||||
case NANOS:
|
||||
amount = Math.multiplyExact(amount, NANOS_PER_DAY);
|
||||
break;
|
||||
|
@ -1935,11 +1935,9 @@ public final class LocalDateTime
|
|||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof LocalDateTime) {
|
||||
LocalDateTime other = (LocalDateTime) obj;
|
||||
return date.equals(other.date) && time.equals(other.time);
|
||||
}
|
||||
return false;
|
||||
return (obj instanceof LocalDateTime other)
|
||||
&& date.equals(other.date)
|
||||
&& time.equals(other.time);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue