Java Second Add addSeconds(Date date, int seconds)

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

Description

add seconds to a date

License

LGPL

Parameter

Parameter Description
date an instance of a date
seconds number of seconds to set

Return

an instance of a date with the seconds added

Declaration

public static Date addSeconds(Date date, int seconds) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

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

public class Main {
    /**/*w  ww  .ja v  a 2  s  . c  o  m*/
     * add seconds to a date
     *
     * @param date    an instance of a date
     * @param seconds number of seconds to set
     * @return an instance of a date with the seconds added
     */
    public static Date addSeconds(Date date, int seconds) {
        final Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.SECOND, seconds);
        return c.getTime();
    }
}

Related

  1. addSecond(Date date, int number)
  2. addSecond(Date date, int numberOfSecond)
  3. addSecond(Date date, int second)
  4. addSecond(Date source, int s)
  5. addSecond(int second)
  6. addSeconds(Date date, int seconds)
  7. addSeconds(final Date date, final int seconds)
  8. addSeconds(int addSeconds)