YearMonth plus(TemporalAmount amountToAdd) example
Description
YearMonth plus(TemporalAmount amountToAdd)
returns a copy of this year-month with the specified amount added.
Syntax
plus
has the following syntax.
public YearMonth plus(TemporalAmount amountToAdd)
Example
The following example shows how to use plus
.
import java.time.Period;
import java.time.YearMonth;
/* w w w .j a v a 2 s . co m*/
public class Main {
public static void main(String[] args) {
YearMonth y = YearMonth.now();
YearMonth s = y.plus(Period.ofYears(3));
System.out.println(s);
}
}
The code above generates the following result.