Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Order of Java 8's datetime package DayOfWeek enum [closed]

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.

like image 596
chama Avatar asked Apr 24 '18 18:04

chama


2 Answers

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]).
like image 55
Andy Turner Avatar answered Nov 20 '22 12:11

Andy Turner


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

like image 32
Magd Kudama Avatar answered Nov 20 '22 12:11

Magd Kudama