Here you can find the source of toDaysBeforeOrAfter(Date date, Integer days)
public static Date toDaysBeforeOrAfter(Date date, Integer days)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static Date toDaysBeforeOrAfter(Date date, Integer days) { return add(date, Calendar.DAY_OF_YEAR, days); }/* ww w . j a va 2 s .c o m*/ private static Date add(Date date, int field, int value) { Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(date.getTime()); cal.add(field, value); return cal.getTime(); } }