Here you can find the source of getDateBefore(Date d, int day)
public static Date getDateBefore(Date d, int day)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static Date getDateBefore(Date d, int day) { Calendar now = Calendar.getInstance(); now.setTime(d);/* w w w .j a va 2s. c o m*/ now.set(Calendar.HOUR_OF_DAY, 0); now.set(Calendar.MINUTE, 0); now.set(Calendar.SECOND, 0); now.set(Calendar.MILLISECOND, 0); now.set(Calendar.DATE, now.get(Calendar.DATE) - day); return now.getTime(); } }