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