8268469: Update java.time to use switch expressions

Reviewed-by: lancea, naoto, dfuchs, iris, chegar
This commit is contained in:
Patrick Concannon 2021-06-25 15:42:38 +00:00
parent ffa34ed429
commit 1d167978e5
22 changed files with 256 additions and 337 deletions

View file

@ -210,11 +210,11 @@ public interface ChronoZonedDateTime<D extends ChronoLocalDate>
@Override
default long getLong(TemporalField field) {
if (field instanceof ChronoField chronoField) {
switch (chronoField) {
case INSTANT_SECONDS: return toEpochSecond();
case OFFSET_SECONDS: return getOffset().getTotalSeconds();
}
return toLocalDateTime().getLong(field);
return switch (chronoField) {
case INSTANT_SECONDS -> toEpochSecond();
case OFFSET_SECONDS -> getOffset().getTotalSeconds();
default -> toLocalDateTime().getLong(field);
};
}
return field.getFrom(this);
}