Here you can find the source of addSeconds(final Date date, final int seconds)
public static Date addSeconds(final Date date, final int seconds)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static final long HOUR = 60 * 60 * 1000; public static final long MINUTE = 60 * 1000; public static final long SECOND = 1000L; public static Date addSeconds(final Date date, final int seconds) { final Calendar c = Calendar.getInstance(); c.setTime(date);// w w w .j av a 2s . com c.add(Calendar.SECOND, seconds); final Date end = c.getTime(); return end; } public static String getTime(final long time) { if (time <= 0) { return ""; } if (time < SECOND) { return time + "ms"; } else if (time < MINUTE) { return (time / SECOND) + "s" + getTime(time % SECOND); } else if (time < HOUR) { return (time / MINUTE) + "m" + getTime(time % MINUTE); } else if (time >= HOUR) { return (time / HOUR) + "h" + getTime(time % HOUR); } return ""; } }