Android examples for java.util:Date Compare
Compare two date value in string, parse them first
import android.text.format.Time; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main{ public static boolean compare2Date(String date1, String date2) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date d1 = null;//from www . ja v a2 s. c o m Date d2 = null; try { d1 = sdf.parse(date1 + ":00"); d2 = sdf.parse(date2 + ":00"); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (d1.getTime() > d2.getTime()) { return true; } else { return false; } } }