Java tutorial
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); public static Date getdatebyDays(int DAYS) { Date today = new Date(); Long Before_Date = (today.getTime() / 1000) - 60 * 60 * 24 * DAYS; today.setTime(Before_Date * 1000); return today; } public static String getDatebyDays(int DAYS) { Date today = new Date(); Long Before_Date = (today.getTime() / 1000) - 60 * 60 * 24 * DAYS; today.setTime(Before_Date * 1000); return format.format(today); } }