LocalDateTime.With Method

Definition

Overloads

Name Description
With(ITemporalField, Int64)

Returns a copy of this date-time with the specified field set to a new value.

With(ITemporalAdjuster)

Returns an adjusted copy of this date-time.

With(ITemporalField, Int64)

Returns a copy of this date-time with the specified field set to a new value.

[Android.Runtime.Register("with", "(Ljava/time/temporal/TemporalField;J)Ljava/time/LocalDateTime;", "", ApiSince=26)]
public Java.Time.Temporal.ITemporal? With(Java.Time.Temporal.ITemporalField? field, long newValue);
[<Android.Runtime.Register("with", "(Ljava/time/temporal/TemporalField;J)Ljava/time/LocalDateTime;", "", ApiSince=26)>]
abstract member With : Java.Time.Temporal.ITemporalField * int64 -> Java.Time.Temporal.ITemporal
override this.With : Java.Time.Temporal.ITemporalField * int64 -> Java.Time.Temporal.ITemporal

Parameters

field
ITemporalField

the field to set in the result, not null

newValue
Int64

the new value of the field in the result

Returns

a LocalDateTime based on this with the specified field set, not null

Attributes

Remarks

Returns a copy of this date-time with the specified field set to a new value. This returns a LocalDateTime, based on this one, with the value for the specified field changed. This can be used to change any supported field, such as the year, month or day-of-month. If it is not possible to set the value, because the field is not supported or for some other reason, an exception is thrown. In some cases, changing the specified field can cause the resulting date-time to become invalid, such as changing the month from 31st January to February would make the day-of-month invalid. In cases like this, the field is responsible for resolving the date. Typically it will choose the previous valid date, which would be the last valid day of February in this example. If the field is a ChronoField then the adjustment is implemented here. The supported fields will behave as per the matching method on LocalDate or LocalTime. All other ChronoField instances will throw an UnsupportedTemporalTypeException. If the field is not a ChronoField, then the result of this method is obtained by invoking TemporalField.adjustInto(Temporal, long) passing this as the argument. In this case, the field determines whether and how to adjust the instant. This instance is immutable and unaffected by this method call.

Java reference for java.time.LocalDateTime.with.

Applies to

With(ITemporalAdjuster)

Returns an adjusted copy of this date-time.

[Android.Runtime.Register("with", "(Ljava/time/temporal/TemporalAdjuster;)Ljava/time/LocalDateTime;", "", ApiSince=26)]
public Java.Time.LocalDateTime? With(Java.Time.Temporal.ITemporalAdjuster? adjuster);
[<Android.Runtime.Register("with", "(Ljava/time/temporal/TemporalAdjuster;)Ljava/time/LocalDateTime;", "", ApiSince=26)>]
member this.With : Java.Time.Temporal.ITemporalAdjuster -> Java.Time.LocalDateTime

Parameters

adjuster
ITemporalAdjuster

the adjuster to use, not null

Returns

a LocalDateTime based on this with the adjustment made, not null

Attributes

Remarks

To be added.

Java reference for java.time.LocalDateTime.with.

Applies to