Here you can find the source of getMonthLastDay(String curmonth, int month)
public static String getMonthLastDay(String curmonth, int month) throws ParseException
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static String getMonthLastDay(String curmonth, int month) throws ParseException { SimpleDateFormat formatter = new SimpleDateFormat("yyyyMM"); Date mydate = formatter.parse(curmonth); Calendar cal = Calendar.getInstance(); cal.setTime(mydate);/*from ww w . ja v a2 s . co m*/ cal.add(Calendar.MONTH, month); SimpleDateFormat daytime = new SimpleDateFormat("yyyyMMdd"); cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH)); return daytime.format(cal.getTime()); } }