Java Day Add addDaysToDate(Date date, int numDays)

Here you can find the source of addDaysToDate(Date date, int numDays)

Description

add Days To Date

License

Open Source License

Declaration

public static Date addDaysToDate(Date date, int numDays) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {

    public static Date addDaysToDate(Date date, int numDays) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);//from ww w.j a va  2s  .com
        c.add(Calendar.DATE, numDays);
        return c.getTime();
    }

    public static String getTime(java.util.Date date) {
        return format(date, "HH:mm:ss");
    }

    public static String format(java.util.Date date, String format) {
        String result = "";
        try {
            if (date != null) {
                java.text.DateFormat df = new java.text.SimpleDateFormat(format);
                result = df.format(date);
            }
        } catch (Exception e) {
        }
        return result;
    }

    public static String format(java.util.Date date) {
        return format(date, "yyyy/MM/dd");
    }
}

Related

  1. addDays2Date(Date d, int days)
  2. addDays2Date(String str, int days)
  3. addDaysByFormatter(int days, String dateFormat)
  4. addDaysDate(final java.util.Date date1, final int nbdays)
  5. addDaysOnDate(final Date date, final int numberOfDays)
  6. addDaysToDate(Date date, int value)
  7. addDaysToDate(final Date d, final int days)
  8. addDaysToDate(String s, int day, String format)
  9. addDayString5(Date date, int day)