YearMonth plus(long amountToAdd, TemporalUnit unit) example
Description
YearMonth plus(long amountToAdd, TemporalUnit unit)
returns a copy of this year-month with the specified amount added.
Syntax
plus
has the following syntax.
public YearMonth plus(long amountToAdd, TemporalUnit unit)
Example
The following example shows how to use plus
.
import java.time.YearMonth;
import java.time.temporal.ChronoUnit;
// ww w . j a v a2 s . c om
public class Main {
public static void main(String[] args) {
YearMonth y = YearMonth.now();
YearMonth s = y.plus(3,ChronoUnit.YEARS);
System.out.println(s);
}
}
The code above generates the following result.