Here you can find the source of dateDiff(Date date1, Date date2)
public static String dateDiff(Date date1, Date date2)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static String dateDiff(Date date1, Date date2) { long milliseconds1 = date1.getTime(); long milliseconds2 = date2.getTime(); long diff = milliseconds2 - milliseconds1; long diffSeconds = diff / 1000; long diffMinutes = diff / (60 * 1000); long diffHours = diff / (60 * 60 * 1000); long diffDays = diff / (24 * 60 * 60 * 1000); diffSeconds = diffSeconds - (diffMinutes * 60); diffMinutes = diffMinutes - (diffHours * 60); diffHours = diffHours - (diffDays * 24); return ((diffHours < 10 ? "0" : "") + diffHours + ":" + (diffMinutes < 10 ? "0" : "") + diffMinutes + ":" + (diffSeconds < 10 ? "0" : "") + diffSeconds); }// w w w . j av a 2s . c om }