YearMonth plusYears(long yearsToAdd)
returns a copy of this year-month with the specified period in years added.
plusYears
has the following syntax.
public YearMonth plusYears(long yearsToAdd)
The following example shows how to use plusYears
.
import java.time.YearMonth; /*from w ww. ja v a2s . c om*/ public class Main { public static void main(String[] args) { YearMonth y = YearMonth.now(); YearMonth s = y.plusYears(3); System.out.println(s); } }
The code above generates the following result.