Java Day Add addDays(Date date, int days)

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

Description

add Days

License

Apache License

Declaration

public static Date addDays(Date date, int days) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static Date addDays(Date date, int days) {
        return add(date, Calendar.DATE, days);
    }//from  w ww .j a v  a2 s .c om

    private static Date add(Date date, int calendarField, int amount) {
        if (date == null) {
            throw new IllegalArgumentException("The date must not be null");
        }
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(calendarField, amount);
        return c.getTime();
    }
}

Related

  1. addDays(Date d, int days)
  2. addDays(Date d, int n)
  3. addDays(Date date, int amount)
  4. addDays(Date date, int count)
  5. addDays(Date date, int day)
  6. addDays(Date date, int days)
  7. addDays(Date date, int days)
  8. addDays(Date date, int days)
  9. addDays(Date date, int days)