add second to date java

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

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
pinned-register now
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