Here you can find the source of nextMonth(Date date)
public static Date nextMonth(Date date)
//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 nextMonth(Date date) { Calendar temp = Calendar.getInstance(); temp.setTime(date);// w w w. j a v a2 s .c o m int y = temp.get(Calendar.YEAR); int m = temp.get(Calendar.MONTH) + 1; int d = temp.get(Calendar.DAY_OF_MONTH); String sj1 = ""; if (d >= 1 && d <= 20) { d = 21; sj1 = String.valueOf(y) + "-" + String.valueOf(m) + "-" + String.valueOf(d); } else if (d >= 21) { if (m == 12) { y += 1; m = 1; } else { m += 1; } d = 21; sj1 = String.valueOf(y) + "-" + String.valueOf(m) + "-" + String.valueOf(d); } SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); Date r_date = null; try { r_date = myFormatter.parse(sj1); } catch (ParseException e) { e.printStackTrace(); } return r_date; } }