Android Date Add add(Date date, int calendarField, int amount)

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

Description

add

Declaration

public static Timestamp add(Date date, int calendarField, int amount) 

Method Source Code

//package com.java2s;

import java.sql.Timestamp;

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

public class Main {
    public static Timestamp add(Date date, int calendarField, int amount) {
        if (date == null) {
            throw new IllegalArgumentException("The date must not be null");
        }/*from   w w w  . ja va 2s  .  c om*/
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(calendarField, amount);
        return new Timestamp(c.getTimeInMillis());
    }
}

Related

  1. add(Date date, int calendarField, int amount)
  2. add(Date date, int calendarField, int amount)
  3. addDay(Date date, int days)
  4. addDays(Date date, int amount)
  5. addDays(Date date, int amount)