I’m trying to compare two dates together and I only want to compare the date part not the time part this is how I store date inside my program :
Thu Jan 27 23:20:00 GMT 2011
I have an:
ArrayList<Date> dateList;
and I want to use
dateList.compares(newDate);
// if the answer was false which means I
// have new date then add the newdate to my list
but since the time part also is involved I can’t get the proper answer.
How can I fix my problem?
I don’t want use JODA-TIME
You can compare value by value like this
Or
If you work with Date class, consider using Calendar class instead
Here’s the most elegant solution, using Calendar and Comparator for this
Usage: