Here you can find the source of getSecondBetweenDate(Date d1, Date d2)
public static Integer getSecondBetweenDate(Date d1, Date d2)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); public static Integer getSecondBetweenDate(Date d1, Date d2) { Long second = (d2.getTime() - d1.getTime()) / 1000; return second.intValue(); }/*from ww w .jav a2 s .c om*/ public static String getTime(String pattern) { return new SimpleDateFormat(pattern).format(new Date()); } }