mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8265746: Update java.time to use instanceof pattern variable (part II)
Reviewed-by: dfuchs, lancea, rriggs, chegar, naoto
This commit is contained in:
parent
a85f6cbbaa
commit
45c5da0fd3
20 changed files with 104 additions and 152 deletions
|
@ -967,12 +967,11 @@ public final class OffsetDateTime
|
|||
*/
|
||||
@Override
|
||||
public OffsetDateTime with(TemporalField field, long newValue) {
|
||||
if (field instanceof ChronoField) {
|
||||
ChronoField f = (ChronoField) field;
|
||||
switch (f) {
|
||||
if (field instanceof ChronoField chronoField) {
|
||||
switch (chronoField) {
|
||||
case INSTANT_SECONDS: return ofInstant(Instant.ofEpochSecond(newValue, getNano()), offset);
|
||||
case OFFSET_SECONDS: {
|
||||
return with(dateTime, ZoneOffset.ofTotalSeconds(f.checkValidIntValue(newValue)));
|
||||
return with(dateTime, ZoneOffset.ofTotalSeconds(chronoField.checkValidIntValue(newValue)));
|
||||
}
|
||||
}
|
||||
return with(dateTime.with(field, newValue), offset);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue