I have Two String Datetime as follows:
String Date1 = \"05-09-2013 10:46:10\"
String Date2 = \"06-09-2013 10:46:10\"
I Need to compare thes
You can use following:
public static boolean CheckDates(String startDate, String endDate) {
SimpleDateFormat dfDate = new SimpleDateFormat("dd-MMM-yyyy");
boolean b = false;
try {
if (dfDate.parse(startDate).before(dfDate.parse(endDate))) {
b = true; // If start date is before end date.
} else if (dfDate.parse(startDate).equals(dfDate.parse(endDate))) {
b = true; // If two dates are equal.
} else {
b = false; // If start date is after the end date.
}
} catch (ParseException e) {
e.printStackTrace();
}
return b;
}