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 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()); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

**Output:**

Day of the Week : TUESDAY - 2 Day of the Week before 10 days: SATURDAY - 6

**Program 2:**

`// 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()); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

**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-

Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.

## Recommended Posts:

- DayOfWeek of() method in Java with Examples
- DayOfWeek plus() method in Java with Examples
- DayOfWeek values() method in Java with Examples
- DayOfWeek getValue() method in Java with Examples
- DayOfWeek get() method in Java with Examples
- DayOfWeek adjustInto() method in Java with Examples
- DayOfWeek valueOf() method in Java with Examples
- DayOfWeek getDisplayName() method in Java with Examples
- DayOfWeek from() method in Java with Examples
- WeekFields dayOfWeek() method in Java with Examples
- Duration minus(Duration) method in Java with Examples
- Duration minus(long, TemporalUnit) method in Java with Examples
- Period minus() method in Java with Examples
- Year minus(long,unit) method in Java with Examples
- LocalDate minus() method in Java with Examples
- ZonedDateTime minus() method in Java with Examples
- Instant minus() method in Java with Examples
- LocalTime minus() method in Java with Examples
- LocalDateTime minus() method in Java with Examples
- OffsetTime minus() method in Java with examples

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.