Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Calendar; import static java.util.Calendar.MONTH; import static java.util.Calendar.YEAR; public class Main { /** * set to the last day of month * @param calendar */ public static void setToLastDay(Calendar calendar) { int year = getYear(calendar); int month = getMonth(calendar); int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); calendar.clear(); calendar.set(year, month, maxDay); calendar.getTimeInMillis(); } public static int getYear(Calendar calendar) { return calendar.get(YEAR); } public static int getMonth(Calendar calendar) { return calendar.get(MONTH); } }