Android Date Add addDays(Date date, int amount)

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

Description

add Days

Declaration

public static Timestamp addDays(Date date, 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 addDays(Date date, int amount) {
        return add(date, Calendar.DAY_OF_MONTH, amount);
    }//from  www .  j av a  2 s.  c o  m

    public static Timestamp add(Date date, int calendarField, int amount) {
        if (date == null) {
            throw new IllegalArgumentException("The date must not be null");
        }
        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. add(Date date, int calendarField, int amount)
  4. addDay(Date date, int days)
  5. addDays(Date date, int amount)
  6. addDaysToDate(Date date, int daysToBeAdded)
  7. addHours(Date date, int amount)
  8. addHours(Date date, int amount)