DayOfWeek valueOf(String name) example
Description
DayOfWeek valueOf(String name)
returns the enum constant
of this type with the specified name.
Syntax
valueOf
has the following syntax.
public static DayOfWeek valueOf(String name)
Example
The following example shows how to use valueOf
.
import java.time.DayOfWeek;
// w w w . j ava 2 s . c o m
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.