Java Date Add addDate(Date date, int amount, int type)

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

Description

add Date

License

Open Source License

Declaration

public static Date addDate(Date date, int amount, int type) 

Method Source Code

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

import java.util.*;

public class Main {
    private final static Calendar cal = Calendar.getInstance();

    public static Date addDate(Date date, int amount, int type) {

        cal.setTime(date);/*from  w ww . j  a  v a2 s .  c  o m*/
        // cal.add(field, amount)

        switch (type) {
        case Calendar.DATE:
            cal.add(Calendar.DATE, amount);

        }
        return cal.getTime();

    }

    public static Date addDate(long time, int amount, int type) {
        Date date = new Date(time);

        return addDate(date, amount, type);

    }
}

Related

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