Java Date Add DateAdd3Days(String _date)

Here you can find the source of DateAdd3Days(String _date)

Description

Date Add Days

License

Apache License

Declaration

public static String DateAdd3Days(String _date) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

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

public class Main {
    private static final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    public static String DateAdd3Days(String _date) {
        Calendar cl = Calendar.getInstance();
        Date date = null;/*from   w  w w .j  ava2s . c o  m*/
        try {
            date = (Date) simpleDateFormat.parse(_date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        cl.setTime(date);
        cl.add(Calendar.DAY_OF_YEAR, 3);
        date = cl.getTime();
        return simpleDateFormat.format(date);
    }

    public static String DateAdd3Days(Date _date) {
        Calendar cl = Calendar.getInstance();
        cl.setTime(_date);
        cl.add(Calendar.DAY_OF_YEAR, 3);
        _date = cl.getTime();
        return simpleDateFormat.format(_date);
    }
}

Related

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