I was looking at the tutorial for Java 8's new datetime package. On the page about the DayOfWeek
and Month
enums, it said that the DayOfMonth
enum runs from Monday to Sunday. Why is that? Every other system I've used (including .NET) has the week starting on Sunday.
Probably because of ISO8601, as described on timeanddate.com:
According to international standard ISO 8601, Monday is the first day of the week. It is followed by Tuesday, Wednesday, Thursday, Friday, and Saturday. Sunday is the 7th and final day.
Although this is the international standard, several countries, including the United States, Canada, and Australia consider Sunday as the start of the week.
Some more direct quotes from the 1988 version of the standard can be found here:
- Annex A.3 .... For commercial purposes, i.e. accounting, planning and similar purposes for which a week number might be used, Monday has been found the most appropriate as the first day of the week.
- 3.17 week, calendar: A seven day period within a calendar year, starting on a Monday and identified by its ordinal number within the year; the first calendar week of the year is the one that includes the first Thursday of that year. In the Gregorian calendar this is equivalent to the week which includes 4 January.
- 5.2.3 .... Day of the week is represented by one decimal digit. Monday shall be identified as day [1] of any calendar week, and subsequent days of the same week shall be numbered in ascending sequence to Sunday (day [7]).
From the JavaDocs:
Each day-of-week has an int value. The int value follows the ISO-8601 standard, from 1 (Monday) to 7 (Sunday). It is recommended that applications use the enum rather than the int value to ensure code clarity.
https://docs.oracle.com/javase/8/docs/api/java/time/DayOfWeek.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With