Here you can find the source of addDays(Date dateToAdd, int numberOfDay)
Parameter | Description |
---|---|
dateToAdd | The date |
numberOfDay | The number of days to add |
private static Date addDays(Date dateToAdd, int numberOfDay)
//package com.java2s; import java.util.*; public class Main { /**/* w w w . j a v a 2s.c o m*/ * Add given number of days to a date. * * @param dateToAdd The date * @param numberOfDay The number of days to add * @return new date */ private static Date addDays(Date dateToAdd, int numberOfDay) { if (dateToAdd == null) { throw new IllegalArgumentException("Date can't be null!"); } Calendar tempCal = Calendar.getInstance(); tempCal.setTime(dateToAdd); tempCal.add(Calendar.DATE, numberOfDay); return tempCal.getTime(); } }