DayOfWeek minus() method in Java with Examples
The minus() 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 backward or forward as specified by the passed parameter. The calculation rolls around the end of the week from Monday to Sunday. The specified period may be positive or negative.
public DayOfWeek minus(long days)
DayOfWeek dayOfWeekObject = dayOfWeekObject.minus(long days)
Parameters: This method takes days as parameter where:
Return Value: The function returns an instance of DayOfWeek after advancing by some days backward or forward.
Below programs illustrate the above method:
Day of the Week : TUESDAY - 2 Day of the Week before 10 days: SATURDAY - 6
Day of the Week : SUNDAY - 7 Day of the Week before -3 days: WEDNESDAY - 3
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.