Here you can find the source of getLastDayOfMonth(Date date)
public static Date getLastDayOfMonth(Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static Date getLastDayOfMonth(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date);//from ww w . j av a 2 s .co m c.set(Calendar.DATE, 1); c.add(Calendar.MONTH, 1); c.add(Calendar.DATE, -1); date = c.getTime(); return date; } }