Here you can find the source of addSecond(Date source, int s)
public static Date addSecond(Date source, int s)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static Date addSecond(Date source, int s) { Calendar cal = Calendar.getInstance(); cal.setTime(source);//from www. j a v a2s . co m cal.add(Calendar.SECOND, s); return cal.getTime(); } public static Long getTime(int length, Date date) { String time = String.valueOf(date.getTime()).substring(0, length); return Long.parseLong(time); } }