Java Date Time - Month minus(long months) example








Month minus(long months) returns the month-of-year that is the specified number of months before this one.

Syntax

minus has the following syntax.

public Month minus(long months)

Example

The following example shows how to use minus.

import java.time.LocalDate;
import java.time.Month;
// w  ww .  j ava2  s. co m
public class Main {
  public static void main(String[] args) {
    Month m = Month.from(LocalDate.now());
    
    System.out.println(m.minus(8));

  }
}

The code above generates the following result.