Here you can find the source of getLastMonthdate()
public static Date getLastMonthdate()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public final static SimpleDateFormat sdf = new SimpleDateFormat(); public final static Calendar car = Calendar.getInstance(); public static Date getLastMonthdate() { car.setTimeInMillis(System.currentTimeMillis()); return addMonth(-1); }// ww w .j a v a2s . co m public static Date addMonth(int k) { car.add(Calendar.MONTH, k); return car.getTime(); } public static String getTime(String format) { return formatDate(new Date(), format); } public static String formatDate(Date date, String formater) { sdf.applyPattern(formater); return sdf.format(date); } }