// -------------------------------------------------------------------------
 @Override
 public AbstractDate with(TemporalField field, long newValue) {
   if (field instanceof ChronoField) {
     ChronoField f = (ChronoField) field;
     getChronology().range(f).checkValidValue(newValue, f);
     int nvalue = (int) newValue;
     switch (f) {
       case DAY_OF_WEEK:
         return plusDays(newValue - getDayOfWeek());
       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 resolvePrevious(getProlepticYear(), getMonth(), nvalue);
       case DAY_OF_YEAR:
         return withDayOfYear(nvalue);
       case EPOCH_DAY:
         return resolveEpochDay(newValue);
       case ALIGNED_WEEK_OF_MONTH:
         return plusDays((newValue - getLong(ALIGNED_WEEK_OF_MONTH)) * lengthOfWeek());
       case ALIGNED_WEEK_OF_YEAR:
         return plusDays((newValue - getLong(ALIGNED_WEEK_OF_YEAR)) * lengthOfWeek());
       case MONTH_OF_YEAR:
         return resolvePrevious(getProlepticYear(), nvalue, getDayOfMonth());
       case PROLEPTIC_MONTH:
         return plusMonths(newValue - getProlepticMonth());
       case YEAR_OF_ERA:
         return resolvePrevious(
             getProlepticYear() >= 1 ? nvalue : 1 - nvalue, getMonth(), getDayOfMonth());
       case YEAR:
         return resolvePrevious(nvalue, getMonth(), getDayOfMonth());
       case ERA:
         return newValue == getLong(ERA)
             ? this
             : resolvePrevious(1 - getProlepticYear(), getMonth(), getDayOfMonth());
       default:
         break;
     }
     throw new UnsupportedTemporalTypeException("Unsupported field: " + field);
   }
   return field.adjustInto(this, newValue);
 }