mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8269124: Update java.time to use switch expressions (part II)
Reviewed-by: dfuchs, vtewari, aefimov, iris, lancea, naoto
This commit is contained in:
parent
675a9520b2
commit
8a7b380ebb
16 changed files with 322 additions and 370 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue