Java Date Time - OffsetDateTime minusMonths(long months) example








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

Syntax

minusMonths has the following syntax.

public OffsetDateTime minusMonths(long months)

Example

The following example shows how to use minusMonths.

import java.time.OffsetDateTime;

public class Main {
  public static void main(String[] args) {
    OffsetDateTime o = OffsetDateTime.now();
    OffsetDateTime d =  o.minusMonths(120);
    System.out.println(d);
  }
}

The code above generates the following result.