Here you can find the source of getNextMonth(Date nowdate, int delay)
public static Date getNextMonth(Date nowdate, int delay)
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static Date getNextMonth(Date nowdate, int delay) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); Calendar temp = Calendar.getInstance(); temp.setTime(nowdate);/* w w w.j a v a 2 s.co m*/ int oldMonth = temp.get(Calendar.MONTH); int newMonth = oldMonth + delay; int oldYear = temp.get(Calendar.YEAR); int i, j; if (newMonth > 12) { i = newMonth % 12; j = newMonth / 12; temp.set(Calendar.MONTH, i); temp.set(Calendar.YEAR, j + oldYear); } else { temp.set(Calendar.MONTH, newMonth); } temp.set(Calendar.DATE, temp.get(Calendar.DATE)); String dateString = formatter.format(temp.getTime()); Date strtodate = null; try { strtodate = formatter.parse(dateString); } catch (ParseException e) { e.printStackTrace(); } return strtodate; } }