The of() method of java.time.DayOfWeek is an in-built function in Java which returns an instance of DayOfWeek from an int value. The int value ranges between 1 (Monday) to 7 (Sunday).
public static DayOfWeek of(int dayOfWeek)
DayOfWeek dayOfWeekObject = DayOfWeek.of(int dayOfWeek)
Parameters: This method takes dayOfWeek as parameter where:
- dayOfWeek – is the int value from 1 (Monday) to 7 (Sunday).
- dayOfWeekObject – is an instance of the DayOfWeek object.
Return Value: The function returns an instance of DayOfWeek object.
Below programs illustrate the above method:
Day of the Week - THURSDAY Int Value of THURSDAY - 4
Day of the Week - SUNDAY Int Value of SUNDAY - 7
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.