public function with(TemporalField $field, $newValue)
 {
     if ($field instanceof ChronoField) {
         $f = $field;
         if ($this->getLong($f) === $newValue) {
             return $this;
         }
         switch ($f) {
             case CF::PROLEPTIC_MONTH():
                 $this->getChronology()->range($f)->checkValidValue($newValue, $f);
                 return $this->plusMonths($newValue - $this->getProlepticMonth());
             case CF::YEAR_OF_ERA():
             case CF::YEAR():
             case ERA:
                 $nvalue = $this->getChronology()->range($f)->checkValidIntValue($newValue, $f);
                 switch ($f) {
                     case CF::YEAR_OF_ERA():
                         return $this->withDate($this->isoDate->withYear(($this->getProlepticYear() >= 1 ? $nvalue : 1 - $nvalue) - ThaiBuddhistChronology::YEARS_DIFFERENCE));
                     case CF::YEAR():
                         return $this->withDate($this->isoDate->withYear($nvalue - ThaiBuddhistChronology::YEARS_DIFFERENCE));
                     case ERA:
                         return $this->withDate($this->isoDate->withYear(1 - $this->getProlepticYear() - ThaiBuddhistChronology::YEARS_DIFFERENCE));
                 }
         }
         return $this->withDate($this->isoDate->with($field, $newValue));
     }
     return parent::with($field, $newValue);
 }
 /**
  * Returns a copy of this {@code LocalDateTime} with the year altered.
  * <p>
  * The time does not affect the calculation and will be the same in the result.
  * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month.
  * <p>
  * This instance is immutable and unaffected by this method call.
  *
  * @param int $year the year to set in the result, from MIN_YEAR to MAX_YEAR
  * @return LocalDateTime a {@code LocalDateTime} based on this date-time with the requested year, not null
  * @throws DateTimeException if the year value is invalid
  */
 public function withYear($year)
 {
     return $this->_with($this->date->withYear($year), $this->time);
 }