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
|
@ -1178,9 +1178,9 @@ public final class OffsetTime
|
|||
@Override
|
||||
public long until(Temporal endExclusive, TemporalUnit unit) {
|
||||
OffsetTime end = OffsetTime.from(endExclusive);
|
||||
if (unit instanceof ChronoUnit) {
|
||||
if (unit instanceof ChronoUnit chronoUnit) {
|
||||
long nanosUntil = end.toEpochNano() - toEpochNano(); // no overflow
|
||||
switch ((ChronoUnit) unit) {
|
||||
switch (chronoUnit) {
|
||||
case NANOS: return nanosUntil;
|
||||
case MICROS: return nanosUntil / 1000;
|
||||
case MILLIS: return nanosUntil / 1000_000;
|
||||
|
@ -1360,11 +1360,9 @@ public final class OffsetTime
|
|||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof OffsetTime) {
|
||||
OffsetTime other = (OffsetTime) obj;
|
||||
return time.equals(other.time) && offset.equals(other.offset);
|
||||
}
|
||||
return false;
|
||||
return (obj instanceof OffsetTime other)
|
||||
&& time.equals(other.time)
|
||||
&& offset.equals(other.offset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue