9

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.

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
chama
  • 5,973
  • 14
  • 61
  • 77
  • 4
    Excuse me if it sounds overly frank. It seems that the systems you have used previously (and of which I have also used some) have been designed in the USA without an eye to how weeks look outside USA. Java is used worldwide, and finally they designed the days of the week in respect of the international standard that says that Monday is the first day of the week. – Ole V.V. Apr 24 '18 at 19:29
  • That's true. Being an American, I never even knew there was a concept of starting the week on a day other than Sunday. – chama Apr 24 '18 at 21:09
  • I am not sure, but maybe the 7-day week starting on Sunday was perceived as too tightly coupled with religion (Judaism, Christianlity, Islam, together the Abrahamic tradition) that it couldn’t be accepted as an international standard across faiths (and ateism). Therefore a different first day had to be picked for the international standard. – Ole V.V. Apr 24 '18 at 22:01
  • Isn't Sunday considered part of the _weekend_, in the USA? If so, how can it also be considered the first day of the week there? – jub0bs Apr 24 '18 at 23:44
  • 1
    Pretty sure Sunday was the first day of the week waaaaay before there was a concept of the weekend. – chama Apr 25 '18 at 01:51
  • 1
    Related: https://softwareengineering.stackexchange.com/q/170496/139641 – Andy Turner Apr 25 '18 at 06:39
  • @chama Yes, Sunday was originally the first day of week in all countries where the Christian churches had dominated, and the churches themselves have not really changed their mind. But this is no longer followed at least in European civil society where the commerce rules. US is just a little bit behind with its cultural traditions ;-) By the way, other countries like Israel or Iran or various Arabic countries consider other days as first (Saturday, Friday or even Thursday). – Meno Hochschild Apr 25 '18 at 10:12
  • 3
    I don't understand why this is primarily opinion based. The answer is clearly found in the javadoc, as described in the accepted answer. Can someone please explain. – chama Apr 25 '18 at 14:37

2 Answers2

13

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]).
Andy Turner
  • 137,514
  • 11
  • 162
  • 243
  • 1
    That link in your answer is misleading. I was expecting it to point to the ISO standard, not some other webpage that happens to mention the standard. – jub0bs Apr 24 '18 at 23:47
  • 1
    @Jubobs A link to the official ISO-paper cannot be offered due to copyright laws. You have to buy this paper! But some other websites like wikipedia show some details. – Meno Hochschild Apr 25 '18 at 04:16
  • 1
    @Jubobs I made it more clear. – Andy Turner Apr 25 '18 at 05:15
8

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

Magd Kudama
  • 3,229
  • 2
  • 21
  • 25