So, I want to compare two dates and I have an if loop to function if one date is after the other. My method:
Start and End Dates are user inputted variables and are in the form Month/Day/Year.
String startDate = "02/20/2012";
String endDate = "03/20/2012";
Date startDate1 = new SimpleDateFormat("MM/dd/yyyy").parse(startDate);
Date endDate1 = new SimpleDateFormat("MM/dd/yyyy").parse(endDate);
however, startDate1 is showing this: Mon Feb 20 00:00:00 EST 2012
and,
endDate1 is showing this: Tue Mar 20 00:00:00 EDT 2012
I don't understand what i'm doing wrong here.
The loop:
if (endDate1.after(startDate1)){
blah blah blah
}
toStringmethod confusingly applies the JVM's default time zone when generating the string.