TemporalField.adjustInto

Returns a copy of the specified temporal object with the value of this field set. !(p) This returns a new temporal object based on the specified one with the value for this field changed. For example, on a {@code LocalDate}, this could be used to set the year, month or day-of-month. The returned object has the same observable type as the specified object. !(p) In some cases, changing a field is not fully defined. For example, if the target object is a date representing the 31st January, then changing the month to February would be unclear. In cases like this, the implementation is responsible for resolving the result. Typically it will choose the previous valid date, which would be the last valid day of February _in this example. !(p) There are two equivalent ways of using this method. The first is to invoke this method directly. The second is to use {@link Temporal#_with(TemporalField, long)}: !(pre) // these two lines are equivalent, but the second approach is recommended temporal = thisField.adjustInto(temporal); temporal = temporal._with(thisField); </pre> It is recommended to use the second approach, {@code _with(TemporalField)}, as it is a lot clearer to read _in code. !(p) Implementations should perform any queries or calculations using the fields available _in {@link ChronoField}. If the field is not supported an {@code UnsupportedTemporalTypeException} must be thrown. !(p) Implementations must not alter the specified temporal object. Instead, an adjusted copy of the original must be returned. This provides equivalent, safe behavior for immutable and mutable implementations.

@param !(R) the type of the Temporal object @param temporal the temporal object to adjust, not null @param newValue the new value of the field @return the adjusted temporal object, not null @throws DateTimeException if the field cannot be set @throws UnsupportedTemporalTypeException if the field is not supported by the temporal @throws ArithmeticException if numeric overflow occurs

interface TemporalField
adjustInto

Meta