Here you can find the source of dateAdd(Date date, int days)
Parameter | Description |
---|---|
date | the starting date |
days | the number of days to increment (may be negative) |
public static Date dateAdd(Date date, int days)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { /**/*from w w w.j a v a 2 s .c om*/ * Convenience method to add specified number of days to the given date * @param date the starting date * @param days the number of days to increment (may be negative) * @return the computed date */ public static Date dateAdd(Date date, int days) { Calendar cal = new GregorianCalendar(); cal.setTime(date); cal.add(Calendar.DAY_OF_MONTH, days); return cal.getTime(); } }