mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +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
|
@ -596,8 +596,8 @@ public final class OffsetDateTime
|
|||
*/
|
||||
@Override
|
||||
public int get(TemporalField field) {
|
||||
if (field instanceof ChronoField) {
|
||||
switch ((ChronoField) field) {
|
||||
if (field instanceof ChronoField chronoField) {
|
||||
switch (chronoField) {
|
||||
case INSTANT_SECONDS:
|
||||
throw new UnsupportedTemporalTypeException("Invalid field 'InstantSeconds' for get() method, use getLong() instead");
|
||||
case OFFSET_SECONDS:
|
||||
|
@ -633,8 +633,8 @@ public final class OffsetDateTime
|
|||
*/
|
||||
@Override
|
||||
public long getLong(TemporalField field) {
|
||||
if (field instanceof ChronoField) {
|
||||
switch ((ChronoField) field) {
|
||||
if (field instanceof ChronoField chronoField) {
|
||||
switch (chronoField) {
|
||||
case INSTANT_SECONDS: return toEpochSecond();
|
||||
case OFFSET_SECONDS: return getOffset().getTotalSeconds();
|
||||
}
|
||||
|
@ -1881,11 +1881,9 @@ public final class OffsetDateTime
|
|||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof OffsetDateTime) {
|
||||
OffsetDateTime other = (OffsetDateTime) obj;
|
||||
return dateTime.equals(other.dateTime) && offset.equals(other.offset);
|
||||
}
|
||||
return false;
|
||||
return (obj instanceof OffsetDateTime other)
|
||||
&& dateTime.equals(other.dateTime)
|
||||
&& offset.equals(other.offset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue