Instant.plus

Returns a copy of this instant with the specified amount added. !(p) This returns an {@code Instant}, based on this one, with the amount _in terms of the unit added. If it is not possible to add the amount, because the unit is not supported or for some other reason, an exception is thrown. !(p) If the field is a {@link ChronoUnit} then the addition is implemented here. The supported fields behave as follows: !(ul) !(li){@code NANOS} - Returns an {@code Instant} with the specified number of nanoseconds added. This is equivalent to {@link #plusNanos(long)}. !(li){@code MICROS} - Returns an {@code Instant} with the specified number of microseconds added. This is equivalent to {@link #plusNanos(long)} with the amount multiplied by 1,000. !(li){@code MILLIS} - Returns an {@code Instant} with the specified number of milliseconds added. This is equivalent to {@link #plusNanos(long)} with the amount multiplied by 1,000,000. !(li){@code SECONDS} - Returns an {@code Instant} with the specified number of seconds added. This is equivalent to {@link #plusSeconds(long)}. !(li){@code MINUTES} - Returns an {@code Instant} with the specified number of minutes added. This is equivalent to {@link #plusSeconds(long)} with the amount multiplied by 60. !(li){@code HOURS} - Returns an {@code Instant} with the specified number of hours added. This is equivalent to {@link #plusSeconds(long)} with the amount multiplied by 3,600. !(li){@code HALF_DAYS} - Returns an {@code Instant} with the specified number of half-days added. This is equivalent to {@link #plusSeconds(long)} with the amount multiplied by 43,200 (12 hours). !(li){@code DAYS} - Returns an {@code Instant} with the specified number of days added. This is equivalent to {@link #plusSeconds(long)} with the amount multiplied by 86,400 (24 hours). </ul> !(p) All other {@code ChronoUnit} instances will throw an {@code UnsupportedTemporalTypeException}. !(p) If the field 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 argument. In this case, the unit determines whether and how to perform the addition. !(p) This instance is immutable and unaffected by this method call.

@param amountToAdd the amount of the unit to add to the result, may be negative @param unit the unit of the amount to add, not null @return an {@code Instant} based on this instant with the specified amount added, not null @throws DateTimeException if the addition cannot be made @throws UnsupportedTemporalTypeException if the unit is not supported @throws ArithmeticException if numeric overflow occurs

  1. Instant plus(TemporalAmount amountToAdd)
  2. Instant plus(long amountToAdd, TemporalUnit unit)
    class Instant

Meta