The valueOf() method of java.time.DayOfWeek is an in-built function in Java which takes a string and returns an instance of DayOfWeek corresponding to the string. The string must match exactly to the identifier used to declare a day-of-week constant in this type. Extraneous white space characters are not permitted.
public static DayOfWeek valueOf(String name)
DayOfWeek dayOfWeekObject = DayOfWeek.valueOf(String name)
Parameters: This method takes name as parameter where:
Return Value: The function returns an instance of DayOfWeek corresponding to the name string
Below programs illustrate the above method:
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.