Add 14 to the year in Java
Description
The following code shows how to add 14 to the year.
Example
/*from ww w . j a v a2 s . c om*/
import java.util.Calendar;
import java.util.GregorianCalendar;
public class Main {
public static void main(String[] a) {
GregorianCalendar calendar = new GregorianCalendar();
System.out.println(calendar.get(Calendar.YEAR));
calendar.add(Calendar.YEAR, 14); // 14 years into the future
System.out.println(calendar.get(Calendar.YEAR));
}
}
The code above generates the following result.