Java Date Add addDate(Date date, int add)

Here you can find the source of addDate(Date date, int add)

Description

add Date

License

Apache License

Declaration

public static String addDate(Date date, int add) 

Method Source Code

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

import java.text.SimpleDateFormat;

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

public class Main {
    public static String addDate(Date date, int add) {

        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);/*from w w w .j a  v  a 2 s .c om*/
        calendar.add(Calendar.MONTH, add);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        return formatter.format(calendar.getTime());
    }
}

Related

  1. add(int datePart, int detal, Date date)
  2. add(int field, int value, Date fromDate)
  3. add(long date, int field, int amount)
  4. add30Minutes(Date date)
  5. addCertainTime(java.util.Date date, double hours)
  6. addDate(Date date, int amount, int type)
  7. addDate(Date date, int field, int add)
  8. addDate(Date date, int k)
  9. addDate(Date date, int noOfDays)