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