Aracılığıyla paylaş


DayOfWeek.AdjustInto(ITemporal) Method

Definition

Adjusts the specified temporal object to have this day-of-week.

[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 day-of-week.

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

The adjustment is equivalent to using Temporal#with(TemporalField, long) passing ChronoField#DAY_OF_WEEK as the field. Note that this adjusts forwards or backwards within a Monday to Sunday week. See java.time.temporal.WeekFields#dayOfWeek() for localized week start days. See TemporalAdjuster for other adjusters with more control, such as next(MONDAY).

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 = thisDayOfWeek.adjustInto(temporal);
              temporal = temporal.with(thisDayOfWeek);

For example, given a date that is a Wednesday, the following are output:

dateOnWed.with(MONDAY);     // two days earlier
              dateOnWed.with(TUESDAY);    // one day earlier
              dateOnWed.with(WEDNESDAY);  // same date
              dateOnWed.with(THURSDAY);   // one day later
              dateOnWed.with(FRIDAY);     // two days later
              dateOnWed.with(SATURDAY);   // three days later
              dateOnWed.with(SUNDAY);     // four days later

This instance is immutable and unaffected by this method call.

Java documentation for java.time.DayOfWeek.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