DayOfWeek valueOf(String name)
returns the enum constant
of this type with the specified name.
valueOf
has the following syntax.
public static DayOfWeek valueOf(String name)
The following example shows how to use valueOf
.
import java.time.DayOfWeek; //from w ww. j a va 2 s. c om public class Main { public static void main(String[] args) { DayOfWeek dayOfWeek = DayOfWeek.valueOf("MONDAY"); System.out.println(dayOfWeek.name()); System.out.println(dayOfWeek.getValue()); System.out.println(dayOfWeek.ordinal()); } }
The code above generates the following result.