Here you can find the source of DifferenceInMilliseconds(Date date1, Date date2)
private static double DifferenceInMilliseconds(Date date1, Date date2)
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.util.*; public class Main { private static double DifferenceInMilliseconds(Date date1, Date date2) { return GetTimeInMilliseconds(date1) - GetTimeInMilliseconds(date2); }//from ww w . j ava 2 s .co m private static long GetTimeInMilliseconds(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); return cal.getTimeInMillis() + cal.getTimeZone().getOffset(cal.getTimeInMillis()); } }