java.time.DayOfWeek.plus() Method Example



Description

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

Declaration

Following is the declaration for java.time.DayOfWeek.plus(long days) method.

public DayOfWeek plus(long days)

Parameters

days − the days to add, positive or negative.

Return Value

the resulting day-of-week, not null.

Example

The following example shows the usage of java.time.DayOfWeek.plus(long days) method.

package com.tutorialspoint;

import java.time.DayOfWeek;

public class DayOfWeekDemo {
   public static void main(String[] args) {
 
      DayOfWeek day = DayOfWeek.of(5);
      System.out.println(day);  
      System.out.println(day.plus(1));  
   }
}

Let us compile and run the above program, this will produce the following result −

FRIDAY
SATURDAY
Advertisements