java.time.DayOfWeek.minus() Method Example



Description

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

Declaration

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

public DayOfWeek minus(long days)

Parameters

days − the days to subtract, positive or negative.

Return Value

the resulting day-of-week, not null.

Example

The following example shows the usage of java.time.DayOfWeek.minus(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.minus(1));  
   }
}

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

FRIDAY
THURSDAY
Advertisements