Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static Calendar getCalendarSetToLastDayOfPreviousMonth(Calendar currentMonth) { currentMonth.add(Calendar.MONTH, -1); currentMonth.set(Calendar.DAY_OF_MONTH, currentMonth.getActualMaximum(Calendar.DAY_OF_MONTH)); return currentMonth; } }