Say I've got two dates formatted this way:
date1 = Feb 22, 2011
date2 = Mon Feb 21 08:30:03 EST 2011 (default formatting)
will date2.compareTo(date1);
still work?
I've got a method I'm using to see if certain date values are the same, but its not 开发者_Go百科working. One date is formatted a certain way, and I think this might be problem.
Any insight would be helpful.
It will still work. The comparison is based on the milliseconds of the date. The formatting is used for display, not comparison.
In your example, check to be sure that date1 is not at 12:00:00 AM, which would be a different time than date2.
精彩评论