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
public static String CompareDates(String date1, String date2) {
try{
String pattern = "dd-MMM-yyyy HH:mm:ss";
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
Date Date1 = formatter.parse(date1);
Date Date2 = formatter.parse(date2);
if (Date1 != null && Date2 != null) {
if (Date1 .equals(Date2 ))
{
//Both dates are equal.
}
else{
//both date are not equal("use after and before to check occurrence of dates")
}
}catch (Exception e1){
e1.printStackTrace();
}
}