Month valueOf(String name)
returns the enum constant
of this type with the specified name.
valueOf
has the following syntax.
public static Month valueOf(String name)
The following example shows how to use valueOf
.
import java.time.Month; /*from www. ja va2s .c o m*/ public class Main { public static void main(String[] args) { Month m = Month.valueOf("MAY"); System.out.println(m.getValue()); System.out.println(m.name()); System.out.println(m.ordinal()); } }
The code above generates the following result.