Returns a copy of this year-month with the specified field set to a new value.
!(p)
This returns a {@code YearMonth}, based on this one, with the value
for the specified field changed.
This can be used to change any supported field, such as the year or month.
If it is not possible to set the value, because the field is not supported or for
some other reason, an exception is thrown.
!(p)
If the field is a {@link ChronoField} then the adjustment is implemented here.
The supported fields behave as follows:
!(ul)
!(li){@code MONTH_OF_YEAR} -
Returns a {@code YearMonth} with the specified month-of-year.
The year will be unchanged.
!(li){@code PROLEPTIC_MONTH} -
Returns a {@code YearMonth} with the specified proleptic-month.
This completely replaces the year and month of this object.
!(li){@code YEAR_OF_ERA} -
Returns a {@code YearMonth} with the specified year-of-era
The month and era will be unchanged.
!(li){@code YEAR} -
Returns a {@code YearMonth} with the specified year.
The month will be unchanged.
!(li){@code ERA} -
Returns a {@code YearMonth} with the specified era.
The month and year-of-era will be unchanged.
</ul>
!(p)
In all cases, if the new value is outside the valid range of values for the field
then a {@code DateTimeException} will be thrown.
!(p)
All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}.
!(p)
If the field is not a {@code ChronoField}, then the result of this method
is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)}
passing {@code this} as the argument. In this case, the field determines
whether and how to adjust the instant.
!(p)
This instance is immutable and unaffected by this method call.
@param field the field to set _in the result, not null
@param newValue the new value of the field _in the result
@return a {@code YearMonth} based on {@code this} with the specified field set, not null
@throws DateTimeException if the field cannot be set
@throws UnsupportedTemporalTypeException if the field is not supported
@throws ArithmeticException if numeric overflow occurs
Returns a copy of this year-month with the specified field set to a new value. !(p) This returns a {@code YearMonth}, based on this one, with the value for the specified field changed. This can be used to change any supported field, such as the year or month. If it is not possible to set the value, because the field is not supported or for some other reason, an exception is thrown. !(p) If the field is a {@link ChronoField} then the adjustment is implemented here. The supported fields behave as follows: !(ul) !(li){@code MONTH_OF_YEAR} - Returns a {@code YearMonth} with the specified month-of-year. The year will be unchanged. !(li){@code PROLEPTIC_MONTH} - Returns a {@code YearMonth} with the specified proleptic-month. This completely replaces the year and month of this object. !(li){@code YEAR_OF_ERA} - Returns a {@code YearMonth} with the specified year-of-era The month and era will be unchanged. !(li){@code YEAR} - Returns a {@code YearMonth} with the specified year. The month will be unchanged. !(li){@code ERA} - Returns a {@code YearMonth} with the specified era. The month and year-of-era will be unchanged. </ul> !(p) In all cases, if the new value is outside the valid range of values for the field then a {@code DateTimeException} will be thrown. !(p) All other {@code ChronoField} instances will throw an {@code UnsupportedTemporalTypeException}. !(p) If the field is not a {@code ChronoField}, then the result of this method is obtained by invoking {@code TemporalField.adjustInto(Temporal, long)} passing {@code this} as the argument. In this case, the field determines whether and how to adjust the instant. !(p) This instance is immutable and unaffected by this method call.
@param field the field to set _in the result, not null @param newValue the new value of the field _in the result @return a {@code YearMonth} based on {@code this} with the specified field set, not null @throws DateTimeException if the field cannot be set @throws UnsupportedTemporalTypeException if the field is not supported @throws ArithmeticException if numeric overflow occurs