mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +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
|
@ -311,20 +311,19 @@ public final class MinguoDate
|
|||
//-----------------------------------------------------------------------
|
||||
@Override
|
||||
public MinguoDate with(TemporalField field, long newValue) {
|
||||
if (field instanceof ChronoField) {
|
||||
ChronoField f = (ChronoField) field;
|
||||
if (getLong(f) == newValue) {
|
||||
if (field instanceof ChronoField chronoField) {
|
||||
if (getLong(chronoField) == newValue) {
|
||||
return this;
|
||||
}
|
||||
switch (f) {
|
||||
switch (chronoField) {
|
||||
case PROLEPTIC_MONTH:
|
||||
getChronology().range(f).checkValidValue(newValue, f);
|
||||
getChronology().range(chronoField).checkValidValue(newValue, chronoField);
|
||||
return plusMonths(newValue - getProlepticMonth());
|
||||
case YEAR_OF_ERA:
|
||||
case YEAR:
|
||||
case ERA: {
|
||||
int nvalue = getChronology().range(f).checkValidIntValue(newValue, f);
|
||||
switch (f) {
|
||||
int nvalue = getChronology().range(chronoField).checkValidIntValue(newValue, chronoField);
|
||||
switch (chronoField) {
|
||||
case YEAR_OF_ERA:
|
||||
return with(isoDate.withYear(getProlepticYear() >= 1 ? nvalue + YEARS_DIFFERENCE : (1 - nvalue) + YEARS_DIFFERENCE));
|
||||
case YEAR:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue