Here you can find the source of getMonthEnd(Date date)
public static Date getMonthEnd(Date date)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static Date getMonthEnd(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);//from w w w . ja va2 s.co m calendar.add(Calendar.MONTH, 1); int index = calendar.get(Calendar.DAY_OF_MONTH); calendar.add(Calendar.DATE, (-index)); return calendar.getTime(); } }