Here you can find the source of compDate(Date date1, Date date2)
public static int compDate(Date date1, Date date2)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int compDate(Date date1, Date date2) { Calendar ca1 = Calendar.getInstance(); Calendar ca2 = Calendar.getInstance(); ca1.setTime(date1);/* w w w . ja va2s .com*/ ca2.setTime(date2); int distanceMin = ca1.get(Calendar.MINUTE) - ca2.get(Calendar.MINUTE); return distanceMin; } }