Here you can find the source of getAfterByNMonth(String format, int months)
public static String getAfterByNMonth(String format, int months)
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.Locale; public class Main { public final static String DisplayDateFormat = "yyyy-MM-dd"; public static String getAfterByNMonth(String format, int months) { Calendar c = Calendar.getInstance(); c.setTime(new Date()); c.add(Calendar.MONTH, months); Date newDate = c.getTime(); return formatDate(newDate, format); }// w w w .j av a 2 s .c om public static String formatDate(Date date, String format) { if (date == null) { return ""; } SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format, Locale.CHINA); return simpleDateFormat.format(date); } public static String formatDate(Date date) { return formatDate(date, DisplayDateFormat); } }