Here you can find the source of addYears(Date date, int amount)
public static Timestamp addYears(Date date, int amount)
//package com.java2s; import java.sql.Timestamp; import java.util.Calendar; import java.util.Date; public class Main { public static Timestamp addYears(Date date, int amount) { return add(date, Calendar.YEAR, amount); }//from ww w . ja va2s . co m public static Timestamp add(Date date, int calendarField, int amount) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar c = Calendar.getInstance(); c.setTime(date); c.add(calendarField, amount); return new Timestamp(c.getTimeInMillis()); } }