javadatetimejava-timedayofweeklibrary-design

Order of Java 8's datetime package DayOfWeek enum


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.


Solution

  • 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