Set Calendar.DAY_OF_WEEK using java.time.DayOfWeek -


currently i've got code sets day_of_week on calendar based on java8 java.time.dayofweek object. since integer values these types misaligned, i.e.

calendar.sunday == 1

where

dayofweek.sunday == 7

i wondering if there recommended way convert 1 other. i'm doing this.

calendar.set(calendar.day_of_week, dayofweek.getvalue() == 7 ? 1 : dayofweek.getvalue() + 1); 

dayofweek enum representing 7 days of week - monday, tuesday, wednesday, thursday, friday, saturday , sunday, followed iso-8601 standard, 1 (monday) 7 (sunday). more info click here

but in calender class given in different way i.e., sunday(1) saturday(7).see here.

the approach following guess.


Comments

Popular posts from this blog

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -