Here you can find the source of addDate(Date date, int noOfDays)
Parameter | Description |
---|---|
date | Date from which addtion or subtraction to be done. |
noOfDays | number of days to be added or substracted. |
public static Date addDate(Date date, int noOfDays)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { /**// w w w .j a v a2 s .c o m * Add no of days to a given date, pass negative number if past or to substract date. * @param date Date from which addtion or subtraction to be done. * @param noOfDays number of days to be added or substracted. * @return Date after addition or subtraction. */ public static Date addDate(Date date, int noOfDays) { Calendar c1 = Calendar.getInstance(); c1.setTime(date); c1.add(Calendar.DATE, noOfDays); return c1.getTime(); } }