YearMonth minusMonths(long monthsToSubtract) example
Description
YearMonth minusMonths(long monthsToSubtract)
returns a copy of this year-month with the specified period in months subtracted.
Syntax
minusMonths
has the following syntax.
public YearMonth minusMonths(long monthsToSubtract)
Example
The following example shows how to use minusMonths
.
import java.time.YearMonth;
//from w w w. ja v a 2s. c o m
public class Main {
public static void main(String[] args) {
YearMonth y = YearMonth.now();
YearMonth s = y.minusMonths(12);
System.out.println(s);
}
}
The code above generates the following result.