Here you can find the source of getCompareResult(String date1, String date2)
public static boolean getCompareResult(String date1, String date2)
//package com.java2s; //License from project: Open Source License import java.text.ParsePosition; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static boolean getCompareResult(String date1, String date2) { Calendar calendar1 = Calendar.getInstance(); calendar1.setTime(strToDate(date1)); Calendar calendar2 = Calendar.getInstance(); calendar2.setTime(strToDate(date2)); if (calendar2.after(calendar1)) { return true; }// w ww . j a va 2 s . c o m return false; } public static Date strToDate(String strDate) { return strToDate(strDate, "yyyy-MM-dd"); } public static Date strToDate(String strDate, String format) { if (strDate == null) { return null; } SimpleDateFormat formatter = new SimpleDateFormat(format); ParsePosition pos = new ParsePosition(0); Date strtodate = formatter.parse(strDate, pos); return strtodate; } }