Here you can find the source of addDays(Date dt, int numDays)
Parameter | Description |
---|---|
dt | a parameter |
numDays | Number of days to add/subtract. |
public static Date addDays(Date dt, int numDays)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /** Add a number of days to the given day. Can be a negative number. * @param dt //from w w w .j a v a 2 s . com * @param numDays Number of days to add/subtract. * @return */ public static Date addDays(Date dt, int numDays) { if (dt == null) return null; GregorianCalendar gc = new GregorianCalendar(); gc.setTime(dt); // add one day to this day gc.add(Calendar.DATE, numDays); return gc.getTime(); } }