Java Data Type How to - Add days to Date


We would like to know how to add days to Date.


import java.util.Calendar;
import java.util.Date;
/*  ww  w.  ja va2s  .co  m*/
public class Main {

  public static void main(String[] args) {
    System.out.println(addDays(new Date(), 100));

  public static Date addDays(Date date, Integer days) {
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DAY_OF_MONTH, days);
    return cal.getTime();


The code above generates the following result.