Here you can find the source of endOfLastMonth()
public static long endOfLastMonth()
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static long endOfLastMonth() { Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, 1); cal.set(Calendar.HOUR_OF_DAY, 23); cal.set(Calendar.MINUTE, 59); cal.set(Calendar.SECOND, 59); cal.set(Calendar.MILLISECOND, 999); cal.add(Calendar.DATE, -1); Date date = cal.getTime(); return date.getTime(); }//from w w w. j a va 2s . c o m }