TemporalAdjuster

Strategy for adjusting a temporal object. !(p) 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. !(p) There are two equivalent ways of using a {@code TemporalAdjuster}. The first is to invoke the method on this interface directly. The second is to use {@link Temporal#_with(TemporalAdjuster)}: !(pre) // these two lines are equivalent, but the second approach is recommended temporal = thisAdjuster.adjustInto(temporal); temporal = temporal._with(thisAdjuster); </pre> It is recommended to use the second approach, {@code _with(TemporalAdjuster)}, as it is a lot clearer to read _in code. !(p) The {@link TemporalAdjusters} class contains a standard set of adjusters, available as static methods. These include: !(ul) !(li)finding the first or last day of the month !(li)finding the first day of next month !(li)finding the first or last day of the year !(li)finding the first day of next year !(li)finding the first or last day-of-week within a month, such as "first Wednesday _in June" !(li)finding the next or previous day-of-week, such as "next Thursday" </ul>

@implSpec This interface places no restrictions on the mutability of implementations, however immutability is strongly recommended.

@see TemporalAdjusters @since 1.8

interface TemporalAdjuster {}

Members

Functions

adjustInto
Temporal adjustInto(Temporal temporal)

Adjusts the specified temporal object. !(p) 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. !(p) There are two equivalent ways of using this method. The first is to invoke this method directly. The second is to use {@link Temporal#_with(TemporalAdjuster)}: !(pre) // these two lines are equivalent, but the second approach is recommended temporal = thisAdjuster.adjustInto(temporal); temporal = temporal._with(thisAdjuster); </pre> It is recommended to use the second approach, {@code _with(TemporalAdjuster)}, as it is a lot clearer to read _in code.

Meta