Here you can find the source of compareDate(Date first, Date second)
public static int compareDate(Date first, Date second)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int compareDate(Date first, Date second) { Calendar cf = Calendar.getInstance(); cf.setTime(first);//from w w w . j av a 2 s. co m Calendar cs = Calendar.getInstance(); cs.setTime(second); if (cf.after(cs)) { return 1; } return cf.before(cs) ? -1 : 0; } }