Java DayOfWeek enum
Last Updated : 17 Mar 2025
In Java the DayOfWeek is an enum representing the 7 days of the week. In addition with the textual enum name, every day-of-week has an int value.
Java DayOfWeek enum Declaration
Let's see the declaration of java.time.DayOfWeek.
Enum Constants
| Constants | Description |
|---|---|
| SUNDAY | The singleton instance for the day-of-week of Sunday. |
| MONDAY | The singleton instance for the day-of-week of Monday. |
| TUESDAY | The singleton instance for the day-of-week of Tuesday. |
| WEDNESDAY | The singleton instance for the day-of-week of Wednesday. |
| THURSDAY | The singleton instance for the day-of-week of Thursday. |
| FRIDAY | The singleton instance for the day-of-week of Friday. |
| SATURDAY | The singleton instance for the day-of-week of Saturday. |
Methods of Java DayOfWeek
| Method | Description |
|---|---|
| int get(TemporalField field) | It is used to get the value of the specified field from this day-of-week as an int. |
| boolean isSupported(TemporalField field) | It is used to check if the specified field is supported. |
| DayOfWeek minus(long days) | It is used to return the day-of-week that is the specified number of days before this one. |
| DayOfWeek plus(long days) | It is used to return the day-of-week that is the specified number of days after this one. |
| static DayOfWeek of(int dayOfWeek) | It is used to obtain an instance of DayOfWeek from an int value. |
| static DayOfWeek[] values() | It is used to return an array containing the constants of this enum type, in the order they are declared. |
| Temporal adjustInto(Temporal temporal) | It adjusts the specified temporal object to have this day-of-week. |
| long getLong(TemporalField field) | It gets the value of the specified field from this day-of-week as a long. |
| String getDisplayName(TextStyle style, Locale locale) | It gets the textual representation, such as 'Mon' or 'Friday'. |
| int getValue() | It gets the day-of-week int value. |
| R query(TemporalQueryquery) | It queries this day-of-week using the specified query. |
| ValueRange range(TemporalField field) | It gets the range of valid values for the specified field. |
| static DayOfWeek valueOf(String name) | It returns the enum constant of this type with the specified name. |
Methods inherited from class java.lang.Enum
- clone
- compareTo
- equals
- finalize
- getDeclaringClass
- hashCode
- name
- ordinal
- toString
- valueOf
Java DayOfWeek Example: get()
DayOfWeekExample1.java
Test it NowOutput:
3
Java DayOfWeek Example: of()
DayOfWeekExample2.java
Test it NowOutput:
FRIDAY 4 5
Java DayOfWeek Example: plus()
DayOfWeekExample3.java
Test it NowOutput:
2 5
Java DayOfWeek Example: minus()
DayOfWeekExample4.java
Test it NowOutput:
2 6
Java DayOfWeek Example: getValue()
DayOfWeekExample5.java
Test it NowOutput:
Day of the Week on 13th September 2021 - MONDAY Int Value of MONDAY - 1
Next TopicJava Month Enum