Instant.Plus Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| Plus(ITemporalAmount) |
Returns a copy of this instant with the specified amount added. |
| Plus(Int64, ITemporalUnit) |
Returns a copy of this instant with the specified amount added. |
Plus(ITemporalAmount)
Returns a copy of this instant with the specified amount added.
[Android.Runtime.Register("plus", "(Ljava/time/temporal/TemporalAmount;)Ljava/time/Instant;", "", ApiSince=26)]
public Java.Time.Instant? Plus(Java.Time.Temporal.ITemporalAmount? amountToAdd);
[<Android.Runtime.Register("plus", "(Ljava/time/temporal/TemporalAmount;)Ljava/time/Instant;", "", ApiSince=26)>]
member this.Plus : Java.Time.Temporal.ITemporalAmount -> Java.Time.Instant
Parameters
- amountToAdd
- ITemporalAmount
TemporalAmount: the amount to add, not null
Returns
an Instant based on this instant with the addition made, not null
- Attributes
Remarks
Returns a copy of this instant with the specified amount added. This returns an Instant, based on this one, with the specified amount added. The amount is typically Duration but may be any other type implementing the TemporalAmount interface. The calculation is delegated to the amount object by calling TemporalAmount.addTo(Temporal). The amount implementation is free to implement the addition in any way it wishes, however it typically calls back to plus(long,TemporalUnit). Consult the documentation of the amount implementation to determine if it can be successfully added. This instance is immutable and unaffected by this method call.
Throws: ArithmeticException if numeric overflow occurs
Throws: DateTimeException if the addition cannot be made
Android reference for java.time.Instant.plus.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Applies to
Plus(Int64, ITemporalUnit)
Returns a copy of this instant with the specified amount added.
[Android.Runtime.Register("plus", "(JLjava/time/temporal/TemporalUnit;)Ljava/time/Instant;", "", ApiSince=26)]
public Java.Time.Temporal.ITemporal? Plus(long amountToAdd, Java.Time.Temporal.ITemporalUnit? unit);
[<Android.Runtime.Register("plus", "(JLjava/time/temporal/TemporalUnit;)Ljava/time/Instant;", "", ApiSince=26)>]
abstract member Plus : int64 * Java.Time.Temporal.ITemporalUnit -> Java.Time.Temporal.ITemporal
override this.Plus : int64 * Java.Time.Temporal.ITemporalUnit -> Java.Time.Temporal.ITemporal
Parameters
- amountToAdd
- Int64
long: the amount of the unit to add to the result, may be negative
- unit
- ITemporalUnit
TemporalUnit: the unit of the amount to add, not null
Returns
an Instant based on this instant with the specified amount added, not null
Implements
- Attributes
Remarks
Returns a copy of this instant with the specified amount added. This returns an 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. If the field is a ChronoUnit then the addition is implemented here. The supported fields behave as follows: NANOS - Returns an Instant with the specified number of nanoseconds added. This is equivalent to plusNanos(long). MICROS - Returns an Instant with the specified number of microseconds added. This is equivalent to plusNanos(long) with the amount multiplied by 1,000. MILLIS - Returns an Instant with the specified number of milliseconds added. This is equivalent to plusNanos(long) with the amount multiplied by 1,000,000. SECONDS - Returns an Instant with the specified number of seconds added. This is equivalent to plusSeconds(long). MINUTES - Returns an Instant with the specified number of minutes added. This is equivalent to plusSeconds(long) with the amount multiplied by 60. HOURS - Returns an Instant with the specified number of hours added. This is equivalent to plusSeconds(long) with the amount multiplied by 3,600. HALF_DAYS - Returns an Instant with the specified number of half-days added. This is equivalent to plusSeconds(long) with the amount multiplied by 43,200 (12 hours). DAYS - Returns an Instant with the specified number of days added. This is equivalent to plusSeconds(long) with the amount multiplied by 86,400 (24 hours). All other ChronoUnit instances will throw an UnsupportedTemporalTypeException. If the field is not a ChronoUnit, then the result of this method is obtained by invoking TemporalUnit.addTo(Temporal, long) passing this as the argument. In this case, the unit determines whether and how to perform the addition. This instance is immutable and unaffected by this method call.
Throws: ArithmeticException if numeric overflow occurs
Throws: DateTimeException if the addition cannot be made
Throws: UnsupportedTemporalTypeException if the unit is not supported
Android reference for java.time.Instant.plus.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.