YearMonth plus(long amountToAdd, TemporalUnit unit)
returns a copy of this year-month with the specified amount added.
plus
has the following syntax.
public YearMonth plus(long amountToAdd, TemporalUnit unit)
The following example shows how to use plus
.
import java.time.YearMonth; import java.time.temporal.ChronoUnit; /* www. ja va 2 s . c o m*/ 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.