I am using the recent java.time package and in particular the day of week getter of LocalDate.
I get a nice DayOfWeek enum when calling LocalDate.getDayOfWeek()
.
However, my code should be compatible with some older part of the application that uses the integer value of a Calendar weekday, i.e. obtained from the code Calendar.get(DAY_OF_WEEK)
.
Obviously, in the DayOfWeek enum, SUNDAY value is 7, and in Calendar DAY_OF_WEEK field, SUNDAY value is 1.
So, what choices do I have to convert one into another? Should I convert the LocalDate in java.util.Date and then into a Calendar?