Hi..
I am new to this forum. I want to sort dates according to date,month and year using BeanComparator. My code is like this. But it will sort based on date without considering month and year.
Please help me out to solve this problem
public static Comparator enquiryDateCompare=new Comparator(){ public int compare(Object bean1, Object bean2){ SimpleDateFormat newDate1=new SimpleDateFormat("yyyy-mm-dd"); SimpleDateFormat newDate2=new SimpleDateFormat("yyyy-mm-dd"); Date date1; Date date2; try{ date1=newDate1.parse(((SalesEnquiryBean)bean1).getSalesEnquiryDate()); date2=newDate2.parse(((SalesEnquiryBean)bean2).getSalesEnquiryDate()); return date1.compareTo(date2); }catch(java.text.ParseException ex){ System.out.println("Exception "+ex); } return 0; } };