Java Data Type How to - Add seconds to Date


We would like to know how to add seconds to Date.


/*  w  w w  .  j  a va  2s .  c om*/
import java.util.Calendar;
import java.util.Date;

public class Main {

  public static void main(String[] args) {
    System.out.println(addSeconds(new Date(), 100));

  public static Date addSeconds(Date date, Integer seconds) {
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.SECOND, seconds);
    return cal.getTime();

The code above generates the following result.