@Override JapaneseDate plusDays(long days) { return with(isoDate.plusDays(days)); }
@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 JapaneseDate plusMonths(long months) { return with(isoDate.plusMonths(months)); }
@Override JapaneseDate plusYears(long years) { return with(isoDate.plusYears(years)); }
/** * Returns a copy of this date with the year altered. * <p> * This method changes the year of the date. * If the month-day is invalid for the year, then the previous valid day * will be selected instead. * <p> * This instance is immutable and unaffected by this method call. * * @param era the era to set in the result, not null * @param yearOfEra the year-of-era to set in the returned date * @return a {@code JapaneseDate} based on this date with the requested year, never null * @throws DateTimeException if {@code year} is invalid */ private JapaneseDate withYear(JapaneseEra era, int yearOfEra) { int year = JapaneseChronology.INSTANCE.prolepticYear(era, yearOfEra); return with(isoDate.withYear(year)); }
int aw = ALIGNED_WEEK_OF_MONTH.checkValidIntValue(fieldValues.remove(ALIGNED_WEEK_OF_MONTH)); int dow = DAY_OF_WEEK.checkValidIntValue(fieldValues.remove(DAY_OF_WEEK)); JapaneseDate date = date(y, moy, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(MONTH_OF_YEAR) != moy) { throw new DateTimeException("Strict mode rejected date parsed to a different month"); JapaneseDate date = date(y, 1, 1).plus(aw - 1, WEEKS).with(nextOrSame(DayOfWeek.of(dow))); if (resolverStyle == ResolverStyle.STRICT && date.get(YEAR) != y) { throw new DateTimeException("Strict mode rejected date parsed to a different month");