Java Date Time - DayOfWeek minus(long days) example








DayOfWeek minus(long days) returns the day-of-week that is the specified number of days before this one.

Syntax

minus has the following syntax.

public DayOfWeek minus(long days)

Example

The following example shows how to use minus.

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;
/*from w  w  w.  j  a  v  a2  s. co  m*/
public class Main {
  public static void main(String[] args) {
    LocalDate localDate = LocalDate.of(2014, Month.JUNE, 21);
    DayOfWeek dayOfWeek = DayOfWeek.from(localDate);
    System.out.println(dayOfWeek.getValue());
    dayOfWeek = dayOfWeek.minus(2);
    System.out.println(dayOfWeek.getValue());
  }
}

The code above generates the following result.