Here you can find the source of getLastDayOfMonth(Date firstDate)
public static int getLastDayOfMonth(Date firstDate) throws Exception
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static int getLastDayOfMonth(Date firstDate) throws Exception { Calendar cal = Calendar.getInstance(); cal.setTime(firstDate);//from ww w . ja va 2 s. c om return cal.getActualMaximum(Calendar.DATE); } }