Here you can find the source of diffDateSec(java.util.Date date, java.util.Date date1)
public static long diffDateSec(java.util.Date date, java.util.Date date1)
//package com.java2s; import java.util.concurrent.TimeUnit; public class Main { public static long diffDateSec(java.util.Date date, java.util.Date date1) { long t1 = date1.getTime(); long t2 = date.getTime(); long millis = t2 - t1; long seconds = TimeUnit.MILLISECONDS.toSeconds(millis); return seconds; }// w w w.j a v a 2s. c om public static String getTime(java.util.Date date) { return format(date, "HH:mm:ss"); } public static String format(java.util.Date date, String format) { String result = ""; try { if (date != null) { java.text.DateFormat df = new java.text.SimpleDateFormat(format); result = df.format(date); } } catch (Exception e) { } return result; } public static String format(java.util.Date date) { if (date == null) { return ""; } return format(date, "yyyy/MM/dd"); } }