Here you can find the source of isEqual(String d1, String d2, String format)
public static boolean isEqual(String d1, String d2, String format)
//package com.java2s; //License from project: Apache License import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static boolean isEqual(String d1, String d2, String format) { Date d1Date = toDate(d1, format); Date d2Date = toDate(d2, format); if (d1Date.getTime() == d2Date.getTime()) return true; return false; }/* w w w.ja v a 2 s . co m*/ public static Date toDate(String str) { if (null == str || str.trim().isEmpty()) { return null; } try { DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return fmt.parse(str); } catch (ParseException e) { return null; } } public static Date toDate(String dateString, String format) { try { DateFormat fmt = new SimpleDateFormat(format); return fmt.parse(dateString); } catch (ParseException e) { return null; } } public static long getTime(String s) { return parseMysql(s).getTime(); } public static Date parseMysql(String s) { try { DateFormat fmtTemp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); return fmtTemp.parse(s); } catch (ParseException e) { return null; } } }