public CalendarDate with(final TemporalField field, final long newValue) { if (field instanceof ChronoField) { if (field == ChronoField.INSTANT_SECONDS) { final long tmpMillisOfSecond = millis % MILLIS_PER_SECOND; return new CalendarDate((newValue * MILLIS_PER_SECOND) + tmpMillisOfSecond); } else if (field == ChronoField.MILLI_OF_SECOND) { final long tmpSeconds = millis / MILLIS_PER_SECOND; return new CalendarDate((tmpSeconds * MILLIS_PER_SECOND) + newValue); } else { throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } } else { return field.adjustInto(this, newValue); } }
public CalendarDate with(final TemporalField field, final long newValue) { if (field instanceof ChronoField) { if (field == ChronoField.INSTANT_SECONDS) { final long tmpMillisOfSecond = millis % MILLIS_PER_SECOND; return new CalendarDate((newValue * MILLIS_PER_SECOND) + tmpMillisOfSecond); } else if (field == ChronoField.MILLI_OF_SECOND) { final long tmpSeconds = millis / MILLIS_PER_SECOND; return new CalendarDate((tmpSeconds * MILLIS_PER_SECOND) + newValue); } else { throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } } else { return field.adjustInto(this, newValue); } }
@Override public ChronoLocalDateTimeImpl<D> with(TemporalField field, long newValue) { if (field instanceof ChronoField) { if (field.isTimeBased()) { return with(date, time.with(field, newValue)); } else { return with(date.with(field, newValue), time); } } return date.getChronology().ensureChronoLocalDateTime(field.adjustInto(this, newValue)); }
return field.adjustInto(this, newValue);
return field.adjustInto(this, newValue);
return field.adjustInto(this, newValue);
return field.adjustInto(this, newValue);
return field.adjustInto(this, newValue);
@Override public ChronoZonedDateTime<D> with(TemporalField field, long newValue) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; switch (f) { case INSTANT_SECONDS: return plus(newValue - toEpochSecond(), SECONDS); case OFFSET_SECONDS: { ZoneOffset offset = ZoneOffset.ofTotalSeconds(f.checkValidIntValue(newValue)); return create(dateTime.toInstant(offset), zone); } } return ofBest(dateTime.with(field, newValue), zone, offset); } return toLocalDate().getChronology().ensureChronoZonedDateTime(field.adjustInto(this, newValue)); }
return field.adjustInto(this, newValue);
return field.adjustInto(this, newValue);
return field.adjustInto(this, newValue);
@Override public JapaneseDate with(TemporalField field, long newValue) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; if (getLong(f) == newValue) { // validates unsupported fields return this; } switch (f) { case DAY_OF_YEAR: case YEAR_OF_ERA: case ERA: { int nvalue = getChronology().range(f).checkValidIntValue(newValue, f); switch (f) { case DAY_OF_YEAR: return with(isoDate.plusDays(nvalue - getDayOfYear())); case YEAR_OF_ERA: return this.withYear(nvalue); case ERA: { return this.withYear(JapaneseEra.of(nvalue), yearOfEra); } } } } return with(isoDate.with(field, newValue)); } return field.adjustInto(this, newValue); }
@Override public HijrahDate with(TemporalField field, long newValue) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; f.checkValidValue(newValue); // TODO: validate value int nvalue = (int) newValue; switch (f) { case DAY_OF_WEEK: return plusDays(newValue - dayOfWeek.getValue()); case ALIGNED_DAY_OF_WEEK_IN_MONTH: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_MONTH)); case ALIGNED_DAY_OF_WEEK_IN_YEAR: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_YEAR)); case DAY_OF_MONTH: return resolvePreviousValid(yearOfEra, monthOfYear, nvalue); case DAY_OF_YEAR: return resolvePreviousValid(yearOfEra, ((nvalue - 1) / 30) + 1, ((nvalue - 1) % 30) + 1); case EPOCH_DAY: return new HijrahDate(nvalue); case ALIGNED_WEEK_OF_MONTH: return plusDays((newValue - getLong(ALIGNED_WEEK_OF_MONTH)) * 7); case ALIGNED_WEEK_OF_YEAR: return plusDays((newValue - getLong(ALIGNED_WEEK_OF_YEAR)) * 7); case MONTH_OF_YEAR: return resolvePreviousValid(yearOfEra, nvalue, dayOfMonth); case YEAR_OF_ERA: return resolvePreviousValid(yearOfEra >= 1 ? nvalue : 1 - nvalue, monthOfYear, dayOfMonth); case YEAR: return resolvePreviousValid(nvalue, monthOfYear, dayOfMonth); case ERA: return resolvePreviousValid(1 - yearOfEra, monthOfYear, dayOfMonth); } throw new UnsupportedTemporalTypeException("Unsupported field: " + field); } return field.adjustInto(this, newValue); }
@Override public ThaiBuddhistDate with(TemporalField field, long newValue) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; if (getLong(f) == newValue) { return this; } switch (f) { case PROLEPTIC_MONTH: getChronology().range(f).checkValidValue(newValue, f); return plusMonths(newValue - getProlepticMonth()); case YEAR_OF_ERA: case YEAR: case ERA: { int nvalue = getChronology().range(f).checkValidIntValue(newValue, f); switch (f) { case YEAR_OF_ERA: return with(isoDate.withYear((getProlepticYear() >= 1 ? nvalue : 1 - nvalue) - YEARS_DIFFERENCE)); case YEAR: return with(isoDate.withYear(nvalue - YEARS_DIFFERENCE)); case ERA: return with(isoDate.withYear((1 - getProlepticYear()) - YEARS_DIFFERENCE)); } } } return with(isoDate.with(field, newValue)); } return field.adjustInto(this, newValue); }
@Override public MinguoDate with(TemporalField field, long newValue) { if (field instanceof ChronoField) { ChronoField f = (ChronoField) field; if (getLong(f) == newValue) { return this; } switch (f) { case PROLEPTIC_MONTH: getChronology().range(f).checkValidValue(newValue, f); return plusMonths(newValue - getProlepticMonth()); case YEAR_OF_ERA: case YEAR: case ERA: { int nvalue = getChronology().range(f).checkValidIntValue(newValue, f); switch (f) { case YEAR_OF_ERA: return with(isoDate.withYear(getProlepticYear() >= 1 ? nvalue + YEARS_DIFFERENCE : (1 - nvalue) + YEARS_DIFFERENCE)); case YEAR: return with(isoDate.withYear(nvalue + YEARS_DIFFERENCE)); case ERA: return with(isoDate.withYear((1 - getProlepticYear()) + YEARS_DIFFERENCE)); } } } return with(isoDate.with(field, newValue)); } return field.adjustInto(this, newValue); }
return field.adjustInto(this, newValue);
return field.adjustInto(this, newValue);
return field.adjustInto(this, newValue);