Java examples for java.util:Year
Add the given amount of years to the given calendar.
//package com.java2s; import java.util.Calendar; public class Main { public static void main(String[] argv) throws Exception { Calendar calendar = Calendar.getInstance(); int years = 2; addYears(calendar, years);/* ww w . j a va 2s . c o m*/ } /** * Add the given amount of years to the given calendar. The changes are * reflected in the given calendar. * * @param calendar * The calendar to add the given amount of years to. * @param years * The amount of years to be added to the given calendar. * Negative values are also allowed, it will just go back in * time. */ public static void addYears(Calendar calendar, int years) { calendar.add(Calendar.YEAR, years); } }