title: Error : Comparison method violates its general contract
body: <p>I know there are a lot of questions related to this topic, but I can't fully understand what is causing this error</p>
  
  <pre><code> Collections.sort(noteList,new Comparator&lt;ClassNote&gt;(){
          @Override
          public int compare(ClassNote b, ClassNote a) {
             DateFormat formatter = new SimpleDateFormat("MMMM dd HH:mm", Locale.US);
             try {
                 Date date2 = formatter.parse(b.getCallDate());
                 Date date1 = formatter.parse(a.getCallDate());
                 if ( date1 == null ) {
                     if ( date2 == null) {
                         return 0;
                     }
                     return 1;
                 }
                 if ( date2 == null ) {
                     return -1;
                 }
                 return date2.compareTo(date1);
             } catch (ParseException e) {
                 e.printStackTrace();
                 return 1;
             }
          }
      });
  </code></pre>
  
  <p>Does anyone know why it does not work and how to fix it?</p>