Returns the DayOfWeek enum instance corresponding to the specified day from 1 (Monday) to 7 (Sunday) per ISO-8601 standard.
package com.logicbig.example.dayofweek;
import java.time.DayOfWeek;
public class OfExample2 {
public static void main (String[] args) {
DayOfWeek day = DayOfWeek.of(8);
System.out.println(day);
}
}
Output
Caused by: java.time.DateTimeException: Invalid value for DayOfWeek: 8
at java.time.DayOfWeek.of(DayOfWeek.java:165)
at com.logicbig.example.dayofweek.OfExample2.main(OfExample2.java:12)
... 6 more