Here you can find the source of getMinllisBetween(Date beginDate, Date endDate)
public static long getMinllisBetween(Date beginDate, Date endDate)
//package com.java2s; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static long getMinllisBetween(Date beginDate, Date endDate) { Calendar d1 = new GregorianCalendar(); d1.setTime(beginDate);// w ww . ja va 2s .c om Calendar d2 = new GregorianCalendar(); d2.setTime(endDate); if (d1.after(d2)) { return 0; } long minllis = d2.getTimeInMillis() - d1.getTimeInMillis(); return minllis; } }