Here you can find the source of getLastDayOfMonth(String format)
public static String getLastDayOfMonth(String format)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.GregorianCalendar; public class Main { public static String getLastDayOfMonth(String format) { String strDate = null;//from w w w .j a v a 2 s . c om try { Calendar c = new GregorianCalendar(); SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat( format); // ??????????? c.set(Calendar.DATE, 1); c.roll(Calendar.DATE, -1); strDate = mSimpleDateFormat.format(c.getTime()); } catch (Exception e) { e.printStackTrace(); } return strDate; } }