Here you can find the source of compareDate(Date firstDate, Date secondDate)
public static boolean compareDate(Date firstDate, Date secondDate)
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static final String PATTERN_STANDARD = "yyyy-MM-dd HH:mm:ss"; public static boolean compareDate(Date firstDate, Date secondDate) { if (firstDate == null || secondDate == null) { throw new java.lang.RuntimeException(); }// w w w.j a v a 2 s . c om String strFirstDate = date2String(firstDate, "yyyy-MM-dd"); String strSecondDate = date2String(secondDate, "yyyy-MM-dd"); if (strFirstDate.equals(strSecondDate)) { return true; } return false; } public static String date2String(java.util.Date date, String pattern) { if (date == null) { throw new java.lang.IllegalArgumentException("timestamp null illegal"); } if (pattern == null || pattern.equals("")) { pattern = PATTERN_STANDARD; ; } SimpleDateFormat sdf = new SimpleDateFormat(pattern); return sdf.format(date); } }