mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8268469: Update java.time to use switch expressions
Reviewed-by: lancea, naoto, dfuchs, iris, chegar
This commit is contained in:
parent
ffa34ed429
commit
1d167978e5
22 changed files with 256 additions and 337 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue