YearMonth.With Method

Definition

Overloads

Name Description
With(ITemporalAdjuster)

Returns an adjusted copy of this year-month.

With(ITemporalField, Int64)

Returns a copy of this year-month with the specified field set to a new value.

With(ITemporalAdjuster)

Returns an adjusted copy of this year-month.

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

Parameters

adjuster
ITemporalAdjuster

the adjuster to use, not null

Returns

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

Attributes

Remarks

Returns an adjusted copy of this year-month. This returns a YearMonth, based on this one, with the year-month adjusted. The adjustment takes place using the specified adjuster strategy object. Read the documentation of the adjuster to understand what adjustment will be made. A simple adjuster might simply set the one of the fields, such as the year field. A more complex adjuster might set the year-month to the next month that Halley's comet will pass the Earth. The result of this method is obtained by invoking the TemporalAdjuster.adjustInto(Temporal) method on the specified adjuster passing this as the argument. This instance is immutable and unaffected by this method call.

Java reference for java.time.YearMonth.with.

Applies to

With(ITemporalField, Int64)

Returns a copy of this year-month with the specified field set to a new value.

[Android.Runtime.Register("with", "(Ljava/time/temporal/TemporalField;J)Ljava/time/YearMonth;", "", 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/YearMonth;", "", 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 YearMonth based on this with the specified field set, not null

Implements

Attributes

Remarks

Returns a copy of this year-month with the specified field set to a new value. This returns a YearMonth, 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 or 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. If the field is a ChronoField then the adjustment is implemented here. The supported fields behave as follows: MONTH_OF_YEAR - Returns a YearMonth with the specified month-of-year. The year will be unchanged. PROLEPTIC_MONTH - Returns a YearMonth with the specified proleptic-month. This completely replaces the year and month of this object. YEAR_OF_ERA - Returns a YearMonth with the specified year-of-era The month and era will be unchanged. YEAR - Returns a YearMonth with the specified year. The month will be unchanged. ERA - Returns a YearMonth with the specified era. The month and year-of-era will be unchanged. In all cases, if the new value is outside the valid range of values for the field then a DateTimeException will be thrown. 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.YearMonth.with.

Applies to