Here you can find the source of compareDateFormat(String strDate1, String strDate2, String format)
public static boolean compareDateFormat(String strDate1, String strDate2, String format)
//package com.java2s; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static boolean compareDateFormat(String strDate1, String strDate2, String format) { Date date1 = convertStrToDate(strDate1, format); Date date2 = convertStrToDate(strDate2, format); if (date1.getTime() > date2.getTime()) { return true; }/*from www . jav a 2 s . c o m*/ return false; } public static Date convertStrToDate(String s) { try { DateFormat dateformat = DateFormat.getDateInstance(); Date date = dateformat.parse(s); return date; } catch (Exception exception) { exception.printStackTrace(); Calendar cal = Calendar.getInstance(); cal.set(1900, 0, 1); return cal.getTime(); } } public static Date convertStrToDate(String s, String format) { SimpleDateFormat simpledateformat = new SimpleDateFormat(format); try { Date date = simpledateformat.parse(s); return date; } catch (Exception exception) { exception.printStackTrace(); Calendar cal = Calendar.getInstance(); cal.set(1900, 0, 1); return cal.getTime(); } } }