Compartir a través de


Month.AdjustInto(ITemporal) Method

Definition

Adjusts the specified temporal object to have this month-of-year.

[Android.Runtime.Register("adjustInto", "(Ljava/time/temporal/Temporal;)Ljava/time/temporal/Temporal;", "", ApiSince=26)]
public Java.Time.Temporal.ITemporal? AdjustInto (Java.Time.Temporal.ITemporal? temporal);
[<Android.Runtime.Register("adjustInto", "(Ljava/time/temporal/Temporal;)Ljava/time/temporal/Temporal;", "", ApiSince=26)>]
abstract member AdjustInto : Java.Time.Temporal.ITemporal -> Java.Time.Temporal.ITemporal
override this.AdjustInto : Java.Time.Temporal.ITemporal -> Java.Time.Temporal.ITemporal

Parameters

temporal
ITemporal

the target object to be adjusted, not null

Returns

the adjusted object, not null

Implements

Attributes

Remarks

Adjusts the specified temporal object to have this month-of-year.

This returns a temporal object of the same observable type as the input with the month-of-year changed to be the same as this.

The adjustment is equivalent to using Temporal#with(TemporalField, long) passing ChronoField#MONTH_OF_YEAR as the field. If the specified temporal object does not use the ISO calendar system then a DateTimeException is thrown.

In most cases, it is clearer to reverse the calling pattern by using Temporal#with(TemporalAdjuster):

// these two lines are equivalent, but the second approach is recommended
              temporal = thisMonth.adjustInto(temporal);
              temporal = temporal.with(thisMonth);

For example, given a date in May, the following are output:

dateInMay.with(JANUARY);    // four months earlier
              dateInMay.with(APRIL);      // one months earlier
              dateInMay.with(MAY);        // same date
              dateInMay.with(JUNE);       // one month later
              dateInMay.with(DECEMBER);   // seven months later

This instance is immutable and unaffected by this method call.

Java documentation for java.time.Month.adjustInto(java.time.temporal.Temporal).

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