TemporalAdjusters previous() method in Java with Examples
The previous(DayOfWeek) method of a TemporalAdjusters class is used to return a previous DayOfWeek TemporalAdjuster object which can be used to get a new Date object which is the previous date with the same matching DayOfWeek as passed as a parameter from any Date object on which this TempotralAdjuster is applied.
public static TemporalAdjuster previous(DayOfWeek dayOfWeek)
Parameters: This method accepts dayOfWeek which can be used to get a new Date object which is the previous date with the same matching DayOfWeek.
Return value: This method returns the previous day of the week adjuster.
Below programs illustrate the TemporalAdjusters.previous() method:
Previous day of the week having WEDNESDAY for localdate 1998-10-31 is: 1998-10-28
previous day of the week having THURSDAY for localdate 2029-12-11 is: 2029-12-06
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.