Returns an object of the same type as this object with the specified period added.
!(p)
This method returns a new object based on this one with the specified period added.
For example, on a {@code LocalDate}, this could be used to add a number of years, months or days.
The returned object will have the same observable type as this 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 adding one month would be unclear.
In cases like this, the field 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.
@implSpec
Implementations must check and handle all units defined _in {@link ChronoUnit}.
If the unit is supported, then the addition must be performed.
If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown.
!(p)
If the unit is not a {@code ChronoUnit}, then the result of this method
is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)}
passing {@code this} as the first argument.
!(p)
Implementations must not alter this object.
Instead, an adjusted copy of the original must be returned.
This provides equivalent, safe behavior for immutable and mutable implementations.
@param amountToAdd the amount of the specified unit to add, may be negative
@param unit the unit of the amount to add, not null
@return an object of the same type with the specified period added, not null
@throws DateTimeException if the unit cannot be added
@throws UnsupportedTemporalTypeException if the unit is not supported
@throws ArithmeticException if numeric overflow occurs
Returns an object of the same type as this object with the specified period added. !(p) This method returns a new object based on this one with the specified period added. For example, on a {@code LocalDate}, this could be used to add a number of years, months or days. The returned object will have the same observable type as this 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 adding one month would be unclear. In cases like this, the field 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.
@implSpec Implementations must check and handle all units defined _in {@link ChronoUnit}. If the unit is supported, then the addition must be performed. If unsupported, then an {@code UnsupportedTemporalTypeException} must be thrown. !(p) If the unit is not a {@code ChronoUnit}, then the result of this method is obtained by invoking {@code TemporalUnit.addTo(Temporal, long)} passing {@code this} as the first argument. !(p) Implementations must not alter this object. Instead, an adjusted copy of the original must be returned. This provides equivalent, safe behavior for immutable and mutable implementations.
@param amountToAdd the amount of the specified unit to add, may be negative @param unit the unit of the amount to add, not null @return an object of the same type with the specified period added, not null @throws DateTimeException if the unit cannot be added @throws UnsupportedTemporalTypeException if the unit is not supported @throws ArithmeticException if numeric overflow occurs