Here you can find the source of getMonthEndDate(Date date)
public static Date getMonthEndDate(Date date)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static Date getMonthEndDate(Date date) { GregorianCalendar c = new GregorianCalendar(); c.setTime(date);/*from w w w . j a v a 2 s. c o m*/ int maxMonth = c.getActualMaximum(Calendar.DAY_OF_MONTH); c.set(Calendar.DAY_OF_MONTH, maxMonth); c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE, 59); c.set(Calendar.SECOND, 59); return c.getTime(); } }