Java Date Time - DayOfWeek plus(long days) example








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

Syntax

plus has the following syntax.

public DayOfWeek plus(long days)

Example

The following example shows how to use plus.

import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.Month;
/* w w  w .  j av  a 2  s.  c  o  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.plus(2);
    System.out.println(dayOfWeek.getValue());
  }
}

The code above generates the following result.