java.util.Calendar / .Date and its related classes are confusing as you have learned the hard way. Counting from scratch for the month numbers and the number of days of the week is one of many bad design options made in these old classes.
java.time
Those old classes were supplanted in Java 8, and then java.time . The new classes are inspired by the highly successful Joda-Time framework, intended as its successor, similar in concept but with re-architecture. Defined by JSR 310 . Expanded by the ThreeTen-Extra project. See Tutorial .
DayOfWeek
During the day, use the well-named DayOfWeek enum .
If you want the weekly integer to be compatible with ISO 8601 , where Monday = 1 and Sunday = 7, you can extract this from an instance of DayOfWeek .
Conversion
If you start with the java.util.Calendar object, convert it to java.time.
An Instant is a moment on the timeline in UTC .
Instant instant = myJavaUtilCalendarObject.toInstant();
Apply time zone to get the date, to get the day of the week.
ZoneId zoneId = ZoneId.of( "America/Montreal" ); ZonedDateTime zdt = ZonedDateTime.ofInstant( instant , zoneId ); DayOfWeek dayOfWeek = zdt.getDayOfWeek();
Please note that the time zone is crucial for determining the date and therefore the day of the week. The date is not the same all over the world at the same time. For example, in Paris, a new day appears earlier than in Montreal, for example.
The number of days of the week
Now that we have java.time and this listing is built into Java, I suggest that you freely pass those instances of enum, not the magic number .
But if you insist on integers, ask for DayOfWeek .
int dayOfWeekNumber = dayOfWeek.getValue();
Day string
This enumeration generates a localized string for the name of the day of the week.
String output = dayOfWeek.getDisplayName( TextStyle.FULL , Locale.CANADA_FRENCH );