Language

IChronoZonedDateTime.With(ITemporalField, Int64) Method

Definition

Returns an object of the same type based on a requested field value.

[Android.Runtime.Register("with", "(Ljava/time/temporal/TemporalField;J)Ljava/time/chrono/ChronoZonedDateTime;", "GetWith_Ljava_time_temporal_TemporalField_JHandler:Java.Time.Chrono.IChronoZonedDateTimeInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", 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/chrono/ChronoZonedDateTime;", "GetWith_Ljava_time_temporal_TemporalField_JHandler:Java.Time.Chrono.IChronoZonedDateTimeInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)>]
abstract member With : Java.Time.Temporal.ITemporalField * int64 -> Java.Time.Temporal.ITemporal

Parameters

field
ITemporalField

the field to adjust, not null

newValue
Int64

the requested value of the field

Returns

an adjusted object of the same type, not null

Implements

Attributes

Remarks

Returns an object of the same type based on a requested field value. For example, on a LocalDate, this could be used to set the year, month or day-of-month. The returned object will have the same observable type as this object. In some cases, changing a field is not fully defined. For example, if the target object is a date representing the 31st January, then changing the month to February would be unclear. In cases like this, the temporal implementation or the field resolves the result. The result is typically the previous valid date, which would be the last valid day of February in this example.

Setting OffsetSeconds may not set the result's offset to the requested value. An ISO zoned date-time keeps its current offset if the requested offset is within the allowed range but not valid for its local date-time in that zone. For an offset within the allowed range, the standard non-ISO implementation instead forms an instant using the requested offset and resolves that instant in the existing zone, which can change the local date-time.

Java reference for java.time.chrono.ChronoZonedDateTime.with.

Applies to