How can I compare two dates to see if one is greater or equal to the other?
I tried the following but it fails. I know I must be close.....
------------------------------------------------------------
String dateAgreed = "01/01/2004 10:50:57 AM";
String paymentDate = "01/31/2004 10:50:58 AM";
DateFormat dateFormatter = new SimpleDateFormat("MM/dd/yyyy");
Calendar aCalendar = Calendar.getInstance();
Calendar bCalendar = Calendar.getInstance();
Date dateAgreed_fmt = dateFormatter.parse(dateAgreed);
Date paymentDate_fmt = dateFormatter.parse(paymentDate);
aCalendar.setTime(dateAgreed_fmt);
aCalendar.add(Calendar.DATE, 0);
bCalendar.setTime(paymentDate_fmt);
if (bCalendar.equals(aCalendar)) {
out.println("OK"+"<br>");
out.println("Date Agreed: "+dateAgreed+"<br>");
out.println("Payment Date: " +paymentDate+"<br>");
} else {
out.println("INVALID PAYMENT"+"<br>");
out.println("Date Agreed: "+dateAgreed+"<br>");
out.println("Payment Date: " +paymentDate+"<br>");
}
------------------------------------------------------
Thanks,
Dave