YearMonth plus(TemporalAmount amountToAdd)
returns a copy of this year-month with the specified amount added.
plus
has the following syntax.
public YearMonth plus(TemporalAmount amountToAdd)
The following example shows how to use plus
.
import java.time.Period; import java.time.YearMonth; // w ww.j a v a2 s . c o 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.