title: how to sort date in descending order using comparator
body: <p>I have a bean object <code>testBean</code> with getter setter and methods.I am retrieving the results from the database and storing it in a <code>TreeMap</code></p>
  
  <p>The Output of the <code>Map</code> will look like this:</p>
  
  <pre><code>{Student1 = [testBean[Dept=Science,ID=12,grade=A,Date=12-Jan-2013]]
              [testBean[Dept=Science,ID=12,grade=B,Date=14-Mar-2013]]
  
  {Student2 = [testBean[Dept=Science,ID=02,grade=A,Date=12-Jan-2013]]
              [testBean[Dept=Science,ID=02,grade=A,Date=14-Mar-2013]]
  </code></pre>
  
  <p>I need the Output to be arranged in Descending order so that the latest date comes first. So I am using a comparator to sort the date:</p>
  
  <pre><code>public int DateCompare(Object studentObj, Object anotherStudentObj) {
      SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
      String value = ((testBean) studentObj).getDateTmTrans();
      String value1 = ((testBean) anotherStudentObj).getDateTmTrans();
      int retVal = 0;
  
      try {
  
          Date firstDate = dateFormat.parse(value);
          Date secondDate = dateFormat.parse(value1);     
          retVal = firstDate.compareTo(secondDate);
  
      } catch (ParseException e) {
          e.printStackTrace();
      }       
      return 0;
  }
  </code></pre>
  
  <p>But I couldn't able to sort the date in descending order. Is there any solution to get the desired output?</p>
  
  <p>Any suggestions are welcome</p>
  
  <p>Thanks in advance</p>