The plus() method of java.time.DayOfWeek is an in-built function in Java which takes a long integer as parameter and returns an instance of DayOfWeek after advancing some days forward or backward as specified by the passed parameter. The calculation rolls around the end of the week from Sunday to Monday. The specified period may be positive or negative.
public DayOfWeek plus(long days)
DayOfWeek dayOfWeekObject = dayOfWeekObject.plus(long days)
Parameters: This method takes days as parameter where:
Return Value: The function returns an instance of DayOfWeek after advancing by some days forward or backward.
Below programs illustrate the above method:
Day of the Week : TUESDAY - 2 Day of the Week after 10 days: FRIDAY - 5
Day of the Week : SUNDAY - 7 Day of the Week after -3 days: THURSDAY - 4
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.