Date.equals(Date) fails eventhough Date.toString() prints the same value
Hi All,
I have two dates inDate and outDate.
inDate is produced by parsing a string using SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
outDate is produced by setting the Calendar Objects respective fields and then converted to a date using Date.get()
but inDate.equals(outDate) fails.... why...?
Eventhough .toString() call on both the dates produce the same value.....
Thanks
[416 byte] By [
saracgia] at [2007-11-26 17:54:57]

In both the Strings, from which I compute inDate and outDate, I have not specified milliSeconds...toString() on both the dates prints these values respectivelyFri Feb 09 00:00:00 CET 2007Fri Feb 09 00:00:00 CET 2007
Hi Kajbj,I think you are right about the milliseconds...Date.getTime() on the dates prints slightly different values.....Once I solve it, i write how I solved it.thanks Kajbj
Solve it... Here is the soln.
In inDate, SimpleDateFormat.parse() sets milliseconds to 0 if not specified.. (I guess).
In outDate which I create using Calendar.set() of respective fields, I left out MILLISECOND until now.
Now I set it to 0 and it works..
Thanks all for support
In case you didn't use ((Calendar)c).clear(), you might consider doing this before setting the time on it (e.g, c.set(year,month,day) )