Here you can find the source of getBeforeMonth(int amount)
public static String getBeforeMonth(int amount)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { public static String getBeforeMonth(int amount) { SimpleDateFormat daytime = new SimpleDateFormat("yyyyMM"); Calendar cal = Calendar.getInstance(); cal.setTime(cal.getTime());// w w w .j a va 2 s.c om cal.add(Calendar.MONTH, -amount); String month = daytime.format(cal.getTime()); return month; } }