Java Date Time - LocalDateTime minusMonths(long months) example








LocalDateTime minusMonths(long months) returns a copy of this LocalDateTime with the specified period in months subtracted.

Syntax

minusMonths has the following syntax.

public LocalDateTime minusMonths(long months)

Example

The following example shows how to use minusMonths.

import java.time.LocalDateTime;
//w w  w. j a v  a  2  s  .co m
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.of(2014, 6, 30, 12, 00);
    
    LocalDateTime t = a.minusMonths(10);
    
    System.out.println(t);
  }
}

The code above generates the following result.