Here you can find the source of compare2DateString(String DateStringType, String dateStr1, String dateStr2)
public static int compare2DateString(String DateStringType, String dateStr1, String dateStr2)
//package com.java2s; //License from project: Apache License import java.util.*; import java.text.SimpleDateFormat; public class Main { public static int compare2DateString(String DateStringType, String dateStr1, String dateStr2) { try {// w ww . jav a 2 s . com SimpleDateFormat df = new SimpleDateFormat(DateStringType); Date d1 = df.parse(dateStr1); Date d2 = df.parse(dateStr2); if (d1.after(d2)) { return 0; } else if (d1.equals(d2)) { return 1; } else { return 2; } } catch (Exception e) { return -1; } } }