package com.logicbig.example.dayofweek;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.temporal.ChronoField;
public class GetFieldExample3 {
public static void main (String[] args) {
LocalDate localDate = LocalDate.parse("2016-10-05");
int i = DayOfWeek.from(localDate)
.get(ChronoField.DAY_OF_MONTH);
System.out.println(i);
}
}
Output
Caused by: java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: DayOfMonth
at java.time.temporal.TemporalAccessor.range(TemporalAccessor.java:174)
at java.time.DayOfWeek.range(DayOfWeek.java:285)
at java.time.temporal.TemporalAccessor.get(TemporalAccessor.java:218)
at java.time.DayOfWeek.get(DayOfWeek.java:318)
at com.logicbig.example.dayofweek.GetFieldExample3.main(GetFieldExample3.java:16)
... 6 more