Java Day Add AddUtilDate(String strDate, int iDays)

Here you can find the source of AddUtilDate(String strDate, int iDays)

Description

Add Util Date

License

Open Source License

Declaration

public static java.util.Date AddUtilDate(String strDate, int iDays)
            throws Exception 

Method Source Code

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

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static java.util.Date AddUtilDate(String strDate, int iDays)
            throws Exception {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Date d1 = df.parse(strDate);
        return AddDate(d1, iDays);
    }//from w ww.  j a v  a 2s . co m

    /**
     * 
     * @param date
     *            Date
     * @param days
     *            int
     * @return Date
     */
    public static Date AddDate(Date date, int days) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        long lTmp = c.getTimeInMillis();
        c.setTimeInMillis(lTmp + ((long) days) * 24 * 3600 * 1000);
        return c.getTime();
    }
}

Related

  1. addDaysToDate(String s, int day, String format)
  2. addDayString5(Date date, int day)
  3. addDayToString(String strDate, int days)
  4. addOneDay(String strDate)
  5. addOneDayForamt(String date, String format, Integer addDate)
  6. getAddDay(int day)
  7. getFutrueDate(Date oldDate, int addDay)