Here you can find the source of getDayFormSomeDay(Date date, int n, boolean before)
public static long getDayFormSomeDay(Date date, int n, boolean before)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static long getDayFormSomeDay(Date date, int n, boolean before) { Calendar cal = new GregorianCalendar(); cal.setTime(date);// w w w. ja v a 2 s . c o m if (before) { cal.add(Calendar.DATE, -n); } else { cal.add(Calendar.DATE, n); } return cal.getTime().getTime(); } }