8269124: Update java.time to use switch expressions (part II)

Reviewed-by: dfuchs, vtewari, aefimov, iris, lancea, naoto
This commit is contained in:
Patrick Concannon 2021-07-05 09:08:13 +00:00
parent 675a9520b2
commit 8a7b380ebb
16 changed files with 322 additions and 370 deletions

View file

@ -196,13 +196,12 @@ public interface ChronoZonedDateTime<D extends ChronoLocalDate>
@Override
default int get(TemporalField field) {
if (field instanceof ChronoField chronoField) {
switch (chronoField) {
case INSTANT_SECONDS:
return switch (chronoField) {
case INSTANT_SECONDS ->
throw new UnsupportedTemporalTypeException("Invalid field 'InstantSeconds' for get() method, use getLong() instead");
case OFFSET_SECONDS:
return getOffset().getTotalSeconds();
}
return toLocalDateTime().get(field);
case OFFSET_SECONDS -> getOffset().getTotalSeconds();
default -> toLocalDateTime().get(field);
};
}
return Temporal.super.get(field);
}