Added in API level 26

TemporalAdjuster

@FunctionalInterface interface TemporalAdjuster
ChronoLocalDate

A date without time-of-day or time-zone in an arbitrary chronology, intended for advanced globalization use cases.

ChronoLocalDateTime

A date-time without a time-zone in an arbitrary chronology, intended for advanced globalization use cases.

DayOfWeek

A day-of-week, such as 'Tuesday'.

Era

An era of the time-line.

HijrahDate

A date in the Hijrah calendar system.

Instant

An instantaneous point on the time-line.

JapaneseDate

A date in the Japanese Imperial calendar system.

LocalDate

A date without a time-zone in the ISO-8601 calendar system, such as 2007-12-03.

LocalDateTime

A date-time without a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30.

LocalTime

A time without a time-zone in the ISO-8601 calendar system, such as 10:15:30.

MinguoDate

A date in the Minguo calendar system.

Month

A month-of-year, such as 'July'.

MonthDay

A month-day in the ISO-8601 calendar system, such as --12-03.

OffsetDateTime

A date-time with an offset from UTC/Greenwich in the ISO-8601 calendar system, such as 2007-12-03T10:15:30+01:00.

OffsetTime

A time with an offset from UTC/Greenwich in the ISO-8601 calendar system, such as 10:15:30+01:00.

ThaiBuddhistDate

A date in the Thai Buddhist calendar system.

Year

A year in the ISO-8601 calendar system, such as 2007.

YearMonth

A year-month in the ISO-8601 calendar system, such as 2007-12.

ZoneOffset

A time-zone offset from Greenwich/UTC, such as +02:00.

DayOfWeek.FRIDAY

The singleton instance for the day-of-week of Friday.

DayOfWeek.MONDAY

The singleton instance for the day-of-week of Monday.

DayOfWeek.SATURDAY

The singleton instance for the day-of-week of Saturday.

DayOfWeek.SUNDAY

The singleton instance for the day-of-week of Sunday.

DayOfWeek.THURSDAY

The singleton instance for the day-of-week of Thursday.

DayOfWeek.TUESDAY

The singleton instance for the day-of-week of Tuesday.

DayOfWeek.WEDNESDAY

The singleton instance for the day-of-week of Wednesday.

HijrahDate

A date in the Hijrah calendar system.

HijrahEra

An era in the Hijrah calendar system.

HijrahEra.AH

The singleton instance for the current era, 'Anno Hegirae', which has the numeric value 1.

IsoEra

An era in the ISO calendar system.

IsoEra.BCE

The singleton instance for the era before the current one, 'Before Current Era', which has the numeric value 0.

IsoEra.CE

The singleton instance for the current era, 'Current Era', which has the numeric value 1.

JapaneseDate

A date in the Japanese Imperial calendar system.

JapaneseEra

An era in the Japanese Imperial calendar system.

LocalDate

A date without a time-zone in the ISO-8601 calendar system, such as 2007-12-03.

LocalDateTime

A date-time without a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30.

MinguoDate

A date in the Minguo calendar system.

MinguoEra

An era in the Minguo calendar system.

MinguoEra.BEFORE_ROC

The singleton instance for the era before the current one, 'Before Republic of China Era', which has the numeric value 0.

MinguoEra.ROC

The singleton instance for the current era, 'Republic of China Era', which has the numeric value 1.

Month.APRIL

The singleton instance for the month of April with 30 days.

Month.AUGUST

The singleton instance for the month of August with 31 days.

Month.DECEMBER

The singleton instance for the month of December with 31 days.

Month.FEBRUARY

The singleton instance for the month of February with 28 days, or 29 in a leap year.

Month.JANUARY

The singleton instance for the month of January with 31 days.

Month.JULY

The singleton instance for the month of July with 31 days.

Month.JUNE

The singleton instance for the month of June with 30 days.

Month.MARCH

The singleton instance for the month of March with 31 days.

Month.MAY

The singleton instance for the month of May with 31 days.

Month.NOVEMBER

The singleton instance for the month of November with 30 days.

Month.OCTOBER

The singleton instance for the month of October with 31 days.

Month.SEPTEMBER

The singleton instance for the month of September with 30 days.

ThaiBuddhistDate

A date in the Thai Buddhist calendar system.

ThaiBuddhistEra

An era in the Thai Buddhist calendar system.

ThaiBuddhistEra.BE

The singleton instance for the current era, 'Buddhist Era', which has the numeric value 1.

ThaiBuddhistEra.BEFORE_BE

The singleton instance for the era before the current one, 'Before Buddhist Era', which has the numeric value 0.

Strategy for adjusting a temporal object.

Adjusters are a key tool for modifying temporal objects. They exist to externalize the process of adjustment, permitting different approaches, as per the strategy design pattern. Examples might be an adjuster that sets the date avoiding weekends, or one that sets the date to the last day of the month.

There are two equivalent ways of using a TemporalAdjuster. The first is to invoke the method on this interface directly. The second is to use Temporal.with(TemporalAdjuster):

// these two lines are equivalent, but the second approach is recommended
    temporal = thisAdjuster.adjustInto(temporal);
    temporal = temporal.with(thisAdjuster);
  
It is recommended to use the second approach, with(TemporalAdjuster), as it is a lot clearer to read in code.

The TemporalAdjusters class contains a standard set of adjusters, available as static methods. These include:

  • finding the first or last day of the month
  • finding the first day of next month
  • finding the first or last day of the year
  • finding the first day of next year
  • finding the first or last day-of-week within a month, such as "first Wednesday in June"
  • finding the next or previous day-of-week, such as "next Thursday"

Summary

Public methods
abstract Temporal!
adjustInto(temporal: Temporal!)

Adjusts the specified temporal object.

Public methods

adjustInto

Added in API level 26
abstract fun adjustInto(temporal: Temporal!): Temporal!

Adjusts the specified temporal object.

This adjusts the specified temporal object using the logic encapsulated in the implementing class. Examples might be an adjuster that sets the date avoiding weekends, or one that sets the date to the last day of the month.

There are two equivalent ways of using this method. The first is to invoke this method directly. The second is to use Temporal.with(TemporalAdjuster):

// these two lines are equivalent, but the second approach is recommended
    temporal = thisAdjuster.adjustInto(temporal);
    temporal = temporal.with(thisAdjuster);
  
It is recommended to use the second approach, with(TemporalAdjuster), as it is a lot clearer to read in code.
Parameters
temporal Temporal!: the temporal object to adjust, not null
Return
Temporal! an object of the same observable type with the adjustment made, not null
Exceptions
java.time.DateTimeException if unable to make the adjustment
java.lang.ArithmeticException if numeric overflow occurs