Android Date Add addSeconds(Date date, int amount)

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

Description

add Seconds

Declaration

public static Timestamp addSeconds(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 addSeconds(Date date, int amount) {
        return add(date, Calendar.SECOND, amount);
    }//from   w w  w.j av a2s.  com

    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. addMinutes(Date date, int amount)
  2. addMinutes(Date date, int amount)
  3. addMonths(Date date, int amount)
  4. addMonths(Date date, int amount)
  5. addMonthsToDate(Date date, int monthsToBeAdded)
  6. addSeconds(Date date, int amount)
  7. addWeeks(Date date, int amount)
  8. addWeeks(Date date, int amount)
  9. addYearToDate(Date date, int yearsToBeAdded)