Java Date Add dateAddDay(Date date, int day)

Here you can find the source of dateAddDay(Date date, int day)

Description

date Add Day

License

Open Source License

Declaration

public static Date dateAddDay(Date date, int day) 

Method Source Code

//package com.java2s;

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

public class Main {

    public static Date dateAddDay(Date date, int day) {
        if (date == null)
            return now();

        Calendar c = Calendar.getInstance();

        c.setTime(date);/*  w  w w  . j a  va2 s  .  c  o m*/
        c.add(Calendar.DATE, day);

        return c.getTime();
    }

    public static Date now() {
        Calendar cal = Calendar.getInstance();
        Date currDate = cal.getTime();

        return currDate;
    }
}

Related

  1. dateAdd(final Date baseDateTime, int daysToAdd, boolean chopTime)
  2. dateAdd(int datePart, int amount, Date date)
  3. dateAdd(int interval, Date date, int n)
  4. DateAdd(String strDate, int iCount, int iType)
  5. DateAdd3Days(String _date)
  6. DateAddDays(Date _date, int days)
  7. dateAddDays(Date date, int days)
  8. dateAddDays(Date date, int days)
  9. dateAddDays(Date time, int days, String dateFormat)