Here you can find the source of getDateBefore(Date date, int days)
Parameter | Description |
---|---|
date | a parameter |
days | must be negtive |
public static Date getDateBefore(Date date, int days)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { /**// w w w . j a va 2s .c o m * Get date before the input date according to param-days * * @author Randy Wong * @param date * @param days * must be negtive * @return Date */ public static Date getDateBefore(Date date, int days) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.add(java.util.Calendar.DAY_OF_YEAR, days); return calendar.getTime(); } }