Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static Calendar addYears(long time, int years) { return add(time, years, Calendar.YEAR); } private static Calendar add(long time, int val, int field) { Calendar c = Calendar.getInstance(); c.setTimeInMillis(time); if (field == 666) { c.add(Calendar.MONTH, val * 3); } else { c.add(field, val); } return c; } }