DayOfWeek of() method in Java with Examples Last Updated : 19 Mar, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The of() method of java.time.DayOfWeek is an in-built function in Java which returns an instance of DayOfWeek from an int value. The int value ranges between 1 (Monday) to 7 (Sunday). Method Declaration: public static DayOfWeek of(int dayOfWeek) Syntax: DayOfWeek dayOfWeekObject = DayOfWeek.of(int dayOfWeek) Parameters: This method takes dayOfWeek as parameter where: dayOfWeek - is the int value from 1 (Monday) to 7 (Sunday). dayOfWeekObject - is an instance of the DayOfWeek object. Return Value: The function returns an instance of DayOfWeek object. Below programs illustrate the above method: Program 1: Java // Java Program Demonstrate of() // method of DayOfWeek import java.time.DayOfWeek; class DayOfWeekExample { public static void main(String[] args) { // Getting an instance of DayOfWeek from int value DayOfWeek dayOfWeek = DayOfWeek.of(4); // Printing the day of the week // and its Int value System.out.println("Day of the Week - " + dayOfWeek.name()); System.out.println("Int Value of " + dayOfWeek.name() + " - " + dayOfWeek.getValue()); } } Output: Day of the Week - THURSDAY Int Value of THURSDAY - 4 Program 2: Java // Java Program Demonstrate of() // method of DayOfWeek import java.time.DayOfWeek; class DayOfWeekExample { public static void main(String[] args) { // Getting an instance of DayOfWeek from int value DayOfWeek dayOfWeek = DayOfWeek.of(7); // Printing the day of the week // and its Int value System.out.println("Day of the Week - " + dayOfWeek.name()); System.out.println("Int Value of " + dayOfWeek.name() + " - " + dayOfWeek.getValue()); } } Output: Day of the Week - SUNDAY Int Value of SUNDAY - 7 Reference: https://docs.oracle.com/javase/8/docs/api/java/time/DayOfWeek.html#of-int- Comment More infoAdvertise with us Next Article DayOfWeek values() method in Java with Examples R rupesh_rao Follow Improve Article Tags : Java Java - util package Java-Functions Java-DayOfWeek Practice Tags : Java Similar Reads DayOfWeek valueOf() method in Java with Examples The valueOf() method of java.time.DayOfWeek is an in-built function in Java which takes a string and returns an instance of DayOfWeek corresponding to the string. The string must match exactly to the identifier used to declare a day-of-week constant in this type. Extraneous white space characters ar 1 min read DayOfWeek plus() method in Java with Examples The plus() method of java.time.DayOfWeek is an in-built function in Java which takes a long integer as parameter and returns an instance of DayOfWeek after advancing some days forward or backward as specified by the passed parameter. The calculation rolls around the end of the week from Sunday to Mo 2 min read DayOfWeek get() method in Java with Examples The get() method of java.time.DayOfWeek is an in-built function in Java which takes a TemporalField as parameter and gets the value of the specified field from this day-of-week as an int. The TemporalField is a field of date-time, such as month-of-year or hour-of-minute. Date and time is expressed u 2 min read DayOfWeek minus() method in Java with Examples The minus() method of java.time.DayOfWeek is an in-built function in Java which takes a long integer as parameter and returns an instance of DayOfWeek after advancing some days backward or forward as specified by the passed parameter. The calculation rolls around the end of the week from Monday to S 2 min read DayOfWeek values() method in Java with Examples The values() method of java.time.DayOfWeek is an in-built function in Java which returns an array containing the days of the week, e.g. MONDAY, TUESDAY and so on, in the order they are declared. Method Declaration: public static DayOfWeek[] values() Syntax: DayOfWeek week[] = DayOfWeek.values() Para 2 min read DayOfWeek from() method in Java with Examples The from() method of java.time.DayOfWeek is an in-built function in Java which takes a TemporalAccessor defining a date and returns an instance of DayOfWeek corresponding to that date. A TemporalAccessor represents an arbitrary set of date and time information, which this method converts to an insta 2 min read Like