Here you can find the source of getLastDay(Date dt)
public static int getLastDay(Date dt)
//package com.java2s; import java.sql.Date; import java.util.Calendar; import java.util.GregorianCalendar; public class Main { public static int getLastDay(Date dt) { Calendar cal = Calendar.getInstance(); cal.setTime(dt);/* ww w . j a v a 2s. co m*/ int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH); return lastDay; } public static int getLastDay(int yy, int mm) { GregorianCalendar gc = new GregorianCalendar(yy, mm - 1, 1); return gc.getActualMaximum(GregorianCalendar.DATE); } }