LocalDateTime.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 date-time with the specified amount added. |
| Plus(Int64, ITemporalUnit) |
Returns a copy of this date-time with the specified amount added. |
Plus(ITemporalAmount)
Returns a copy of this date-time with the specified amount added.
[Android.Runtime.Register("plus", "(Ljava/time/temporal/TemporalAmount;)Ljava/time/LocalDateTime;", "", ApiSince=26)]
public Java.Time.LocalDateTime? Plus(Java.Time.Temporal.ITemporalAmount? amountToAdd);
[<Android.Runtime.Register("plus", "(Ljava/time/temporal/TemporalAmount;)Ljava/time/LocalDateTime;", "", ApiSince=26)>]
member this.Plus : Java.Time.Temporal.ITemporalAmount -> Java.Time.LocalDateTime
Parameters
- amountToAdd
- ITemporalAmount
the amount to add, not null
Returns
a LocalDateTime based on this date-time with the addition made, not null
- Attributes
Remarks
Returns a copy of this date-time with the specified amount added. The amount is typically Period or Duration but may be any other type implementing the TemporalAmount interface. For a Period, the date is adjusted and the time is unchanged. For other amounts, the method calls TemporalAmount.addTo(Temporal). The amount implementation determines how to perform the addition. 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.
Java reference for java.time.LocalDateTime.plus.
Applies to
Plus(Int64, ITemporalUnit)
Returns a copy of this date-time with the specified amount added.
[Android.Runtime.Register("plus", "(JLjava/time/temporal/TemporalUnit;)Ljava/time/LocalDateTime;", "", 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/LocalDateTime;", "", 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
the amount of the unit to add to the result, may be negative
- unit
- ITemporalUnit
the unit of the amount to add, not null
Returns
a LocalDateTime based on this date-time with the specified amount added, not null
- Attributes
Remarks
Returns a copy of this date-time with the specified amount added. This returns a LocalDateTime, 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 unit is a ChronoUnit then the addition is implemented here. Date units are added as per LocalDate.plus(long, TemporalUnit). Time units other than HALF_DAYS are added as per LocalTime.plus(long, TemporalUnit), with any overflow in days added to the date. If the unit is not a ChronoUnit, the method calls TemporalUnit.addTo(Temporal, long) with this date-time and the amount; the unit determines how to perform the addition.
For HALF_DAYS, the Android 8 through 17 source releases checked and SDK 37.2 source add amountToAdd / 256 days, then (amountToAdd % 256) * 12 hours. Division truncates toward zero. For example, adding 256 half-days adds one day, not 128 days. This instance is immutable and unaffected by this method call.
Java reference for java.time.LocalDateTime.plus.