Here you can find the source of dateAfter(Date date, int years, int months)
public static Date dateAfter(Date date, int years, int months)
//package com.java2s; /**//from w w w . j a va 2 s .com * Copyright (c) 2014-2015 by Wen Yu. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Any modifications to this file must keep this entire header intact. */ import java.util.Calendar; import java.util.Date; public class Main { public static Date dateAfter(Date date, int years, int months) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.YEAR, years); calendar.add(Calendar.MONTH, months); return calendar.getTime(); } public static Date dateAfter(Date date, int years, int months, int days) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.YEAR, years); calendar.add(Calendar.MONTH, months); calendar.add(Calendar.DAY_OF_MONTH, days); return calendar.getTime(); } public static Date dateAfter(Date date, int years, int months, int days, int hours, int minutes, int seconds, int millisecs) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(Calendar.YEAR, years); calendar.add(Calendar.MONTH, months); calendar.add(Calendar.DAY_OF_MONTH, days); calendar.add(Calendar.HOUR, hours); calendar.add(Calendar.MINUTE, minutes); calendar.add(Calendar.SECOND, seconds); calendar.add(Calendar.MILLISECOND, millisecs); return calendar.getTime(); } }