Java Date Add dateAdd(Date date, int type, int num)

Here you can find the source of dateAdd(Date date, int type, int num)

Description

date Add

License

Apache License

Declaration

public static Date dateAdd(Date date, int type, int num) 

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 dateAdd(Date date, int type, int num) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);/*from w w  w .ja va 2 s.  c o  m*/
        c.add(type, num);
        return c.getTime();
    }

    public static Date dateAdd(Date date, int type1, int num1, int type2, int num2) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(type1, num1);
        c.add(type2, num2);
        return c.getTime();
    }
}

Related

  1. addInteger(Date date, int dateType, int amount)
  2. addSeconds(Date date1, long secs)
  3. dateAdd(Date date, int days)
  4. dateAdd(Date date, int days)
  5. dateAdd(Date date, int field, int amount)
  6. dateAdd(Date date, int val)
  7. dateAdd(final Date baseDateTime, int daysToAdd, boolean chopTime)
  8. dateAdd(int datePart, int amount, Date date)
  9. dateAdd(int interval, Date date, int n)