Here you can find the source of getDiffMon(Date dt, int idiff)
public static final String getDiffMon(Date dt, int idiff)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static final String dtSimple = "yyyy-MM-dd"; public static final String getDiffMon(Date dt, int idiff) { Calendar c = Calendar.getInstance(); c.setTime(dt);//from w w w . j a v a2 s . c o m c.add(Calendar.MONTH, idiff); return dtSimpleFormat(c.getTime()); } /** * yyyy-MM-dd * * @param date * * @return */ public static final String dtSimpleFormat(Date date) { if (date == null) { return ""; } return getFormat(dtSimple).format(date); } private static final DateFormat getFormat(String format) { return new SimpleDateFormat(format); } }