Here you can find the source of getLastMonthLastDate()
public static Date getLastMonthLastDate()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.*; public class Main { public static Date getLastMonthLastDate() { Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.MONTH, -1); int max = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); calendar.set(Calendar.DAY_OF_MONTH, max); return calendar.getTime(); }/*from w ww . ja va2 s .c om*/ public static String getTime() { Date currentTime = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateString = formatter.format(currentTime); String min; min = dateString.substring(14, 16); return min; } }