Here you can find the source of getPrevDueDate(int payperiod, long time)
public static Date getPrevDueDate(int payperiod, long time)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static Date getPrevDueDate(int payperiod, long time) { Calendar now = Calendar.getInstance(); now.setTimeInMillis(time);/* w w w.j a v a 2 s. c o m*/ if (payperiod == 1) { now.add(Calendar.MONTH, -1); } else if (payperiod == 2) { now.add(Calendar.MONTH, -3); } else if (payperiod == 3) { now.add(Calendar.MONTH, -6); } else if (payperiod == 4) { now.add(Calendar.YEAR, -1); } return now.getTime(); } }