Java Day Add addDays2Date(String str, int days)

Here you can find the source of addDays2Date(String str, int days)

Description

add Days Date

License

Open Source License

Declaration


public static Date addDays2Date(String str, int days) throws ParseException 

Method Source Code


//package com.java2s;
import java.text.ParseException;
import java.text.SimpleDateFormat;

import java.util.Date;

public class Main {

    public static Date addDays2Date(String str, int days) throws ParseException {
        SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
        Date date = fmt.parse(str);
        date.setTime(date.getTime() + (long) days * 1000L * 60L * 60L * 24L);
        return date;
    }/*from w w  w.j  a  va 2s . c  o  m*/

    public static Date addDays2Date(Date date, int days) throws ParseException {
        date.setTime(date.getTime() + (long) days * 1000L * 60L * 60L * 24L);
        return date;
    }
}

Related

  1. addDays(String dateStr, int nDays, String inputDateFormat, String outputDateFormat)
  2. addDays(String s, int day)
  3. addDays(String src, int day, String format)
  4. addDays(String startDate, int amount)
  5. addDays2Date(Date d, int days)
  6. addDaysByFormatter(int days, String dateFormat)
  7. addDaysDate(final java.util.Date date1, final int nbdays)
  8. addDaysOnDate(final Date date, final int numberOfDays)
  9. addDaysToDate(Date date, int numDays)