add second to date java

Solutions on MaxInterview for add second to date java by the best coders in the world

showing results for - "add second to date java"
Lenny
29 May 2017
1/*  w  w w  .  j  a va  2s .  c om*/
2import java.util.Calendar;
3import java.util.Date;
4
5public class Main {
6
7  public static void main(String[] args) {
8    System.out.println(addSeconds(new Date(), 100));
9  }
10
11  public static Date addSeconds(Date date, Integer seconds) {
12    Calendar cal = Calendar.getInstance();
13    cal.setTime(date);
14    cal.add(Calendar.SECOND, seconds);
15    return cal.getTime();
16  }
17}
18