Here you can find the source of getLastMonth()
public static String getLastMonth()
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { private static SimpleDateFormat monthFormat = new SimpleDateFormat("yyyy-MM"); public static String getLastMonth() { Calendar a = Calendar.getInstance(); a.setTime(new Date()); a.set(Calendar.DAY_OF_MONTH, -1); return monthFormat.format(a.getTime()); }/* w w w .ja va2 s . c om*/ }