Here you can find the source of getMonthBefore(Date currentDate, int numberMonthBefore)
@SuppressWarnings("deprecation") public static Date getMonthBefore(Date currentDate, int numberMonthBefore)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { @SuppressWarnings("deprecation") public static Date getMonthBefore(Date currentDate, int numberMonthBefore) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, currentDate.getYear() + 1900); calendar.set(Calendar.MONTH, currentDate.getMonth() + 1 - numberMonthBefore); calendar.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE)); return calendar.getTime(); }/*from w w w. ja v a 2 s.c o m*/ }