Java Date Add dateAdd(Date date, int days)

Here you can find the source of dateAdd(Date date, int days)

Description

Convenience method to add specified number of days to the given date

License

Apache License

Parameter

Parameter Description
date the starting date
days the number of days to increment (may be negative)

Return

the computed date

Declaration

public static Date dateAdd(Date date, int days) 

Method Source Code

//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();
    }
}

Related

  1. addDays(Date when, int amount)
  2. addDays(int count, Calendar timestamp)
  3. addDaysToCurrentDate(Integer dayIncrement)
  4. addInteger(Date date, int dateType, int amount)
  5. addSeconds(Date date1, long secs)
  6. dateAdd(Date date, int days)
  7. dateAdd(Date date, int field, int amount)
  8. dateAdd(Date date, int type, int num)
  9. dateAdd(Date date, int val)