Java tutorial
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Calendar; public class Main { private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); public static String getPreviousDate(int days) { Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -days); return sdf.format(cal.getTime()); } }