title: “Comparison method violates its general contract!” : java 7 error with Date data
body: <p><br>
  I have found this issue in multiple threads and tried suggested replies. But didn't get success.</p>
  
  <p>My code is mentioned below:</p>
  
  <pre><code>@Override
  public int compareTo(CustomObject o) {
      try {
          if (getOriginalActionDate() == null || o.getOriginalActionDate() == null) {
              return -1;
          }
          return new SimpleDateFormat("MM/dd/yyyy").parse(
                  getOriginalActionDate()).compareTo(
                  new SimpleDateFormat("MM/dd/yyyy").parse(o
                          .getOriginalActionDate()));
      } catch (Exception e) {
          e.printStackTrace();
      }
      return 0;
  }
  </code></pre>
  
  <p>Please let me know what mistake I am doing here? Any pointer in this regard will be very helpful.</p>
  
  <p>Thanks,<br>
  Gopal lal</p>