DayOfWeek minus() method in Java with Examples Last Updated : 19 Mar, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 Sunday. The specified period may be positive or negative. Method Declaration: public DayOfWeek minus(long days) Syntax: DayOfWeek dayOfWeekObject = dayOfWeekObject.minus(long days) Parameters: This method takes days as parameter where: days – is the number of days to advance forward or backward. dayOfWeekObject – is an instance of DayOfWeek object. Return Value: The function returns an instance of DayOfWeek after advancing by some days backward or forward. Below programs illustrate the above method: Program 1: Java // Java Program Demonstrate minus() // 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(2); // Printing the day of the week and its Int value System.out.println("Day of the Week : " + dayOfWeek.name() + " - " + dayOfWeek.getValue()); // Number of days to advance long adv = 10; // Advancing the day dayOfWeek = dayOfWeek.minus(adv); // Printing the day of the week and its // Int value before adv days System.out.println("Day of the Week before " + adv + " days: " + dayOfWeek.name() + " - " + dayOfWeek.getValue()); } } Output: Day of the Week : TUESDAY - 2 Day of the Week before 10 days: SATURDAY - 6 Program 2: Java // Java Program Demonstrate minus() // 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() + " - " + dayOfWeek.getValue()); // Number of days to advance long adv = -3; // Advancing the day dayOfWeek = dayOfWeek.minus(adv); // Printing the day of the week and its // Int value before adv days System.out.println("Day of the Week before " + adv + " days: " + dayOfWeek.name() + " - " + dayOfWeek.getValue()); } } Output: Day of the Week : SUNDAY - 7 Day of the Week before -3 days: WEDNESDAY - 3 Reference: https://docs.oracle.com/javase/8/docs/api/java/time/DayOfWeek.html#minus-long- Comment More infoAdvertise with us Next Article DayOfWeek valueOf() 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 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 of() method in Java with Examples 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 d 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 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 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 WeekFields dayOfWeek() method in Java with Examples The dayOfWeek() method of WeekFields class is used to return a field to access the day of the week based on this WeekFields. For example, if the first day-of-week is Monday, then that will have the value 1, with other days ranging from Tuesday as 2 to Sunday as 7. Syntax: public TemporalField dayOfW 2 min read Like