Java Date Add add(Date date, int x)

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

Description

add

License

LGPL

Declaration

public static Date add(Date date, int x) 

Method Source Code

//package com.java2s;
/*//ww  w  .j  a va2  s  .  c om
* Distributable under LGPL v3 license.
* See terms of license at https://github.com/Yunfeng/schotel/blob/master/LICENSE
*/

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

public class Main {
    public static Date add(Date date, int x) {
        return addDays(date, x);
    }

    public static Date addDays(Date date, int x) {
        Calendar c = Calendar.getInstance();
        c.clear();
        c.setTime(date);
        c.add(Calendar.DATE, x);
        return c.getTime();
    }
}

Related

  1. add(Date date, int field, int amount)
  2. add(Date date, int field, int amount)
  3. add(Date date, int field, int diff)
  4. add(Date date, int field, int value)
  5. add(Date date, int field, long amount)
  6. add(Date date, long minutes)
  7. add(Date eredeti, int mihez, int mennyit)
  8. add(Date when, int amount, int field)
  9. add(int datePart, int detal, Date date)