Java 8 的日期时间包 DayOfWeek 枚举的顺序
Order of Java 8's datetime package DayOfWeek enum
我正在查看 Java 8 的新日期时间包的教程。在关于 DayOfWeek
and Month
enums 的页面上,它说 DayOfMonth
枚举从星期一到星期日运行。这是为什么?我使用过的所有其他系统(包括 .NET)的星期从星期日开始。
可能是因为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.
可以找到 1988 版标准的一些更直接的引用 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]).
来自 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
我正在查看 Java 8 的新日期时间包的教程。在关于 DayOfWeek
and Month
enums 的页面上,它说 DayOfMonth
枚举从星期一到星期日运行。这是为什么?我使用过的所有其他系统(包括 .NET)的星期从星期日开始。
可能是因为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.
可以找到 1988 版标准的一些更直接的引用 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]).
来自 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