Here you can find the source of getLastDayOfMonth(Calendar c)
public static Date getLastDayOfMonth(Calendar c)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static Date getLastDayOfMonth(Calendar c) { int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH) + 1; int day = 1; if (month > 11) { month = 0;//from w w w .j ava2 s . co m year = year + 1; } c.set(year, month, day - 1, 0, 0, 0); return c.getTime(); } }