Javatpoint Logo
Javatpoint Logo

Java DayOfWeek enum

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.

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.

Java DayOfWeek Example: get()

Test it Now

Output:

3

Java DayOfWeek Example: of()

Test it Now

Output:

FRIDAY
4
5

Java DayOfWeek Example: plus()

Test it Now

Output:

2
5

Java DayOfWeek Example: minus()

Test it Now

Output:

2
6
Next TopicJava Month Enum




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


B.Tech / MCA