Java Calendar Add add(Date _date, int _calendarField, int _amount)

Here you can find the source of add(Date _date, int _calendarField, int _amount)

Description

add

License

Apache License

Declaration

public static Date add(Date _date, int _calendarField, int _amount) 

Method Source Code

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

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

public class Main {

    public static Date add(Date _date, int _calendarField, int _amount) {
        if (_date == null) {
            return _date;
        }//from w  ww.j  av  a 2  s.c  om
        Calendar c = Calendar.getInstance();
        c.setTime(_date);
        c.add(_calendarField, _amount);
        return c.getTime();
    }
}

Related

  1. add(Calendar calendar, int calendarField, int amount)
  2. add(Date date, int calendarField, int amount)
  3. add(Date inputDate, int interval, int calendarUnit)
  4. add(final Date date, final int calendarField, final int amount)
  5. add2Calendar(Calendar cal, int years, int months, int days, int hours, int minutes, int seconds, int millis)