Comparison Method violates its general contract in Java 7
<p>I am getting a "Comparison Method violates its general contract" after compiling some Java code in Java 7, and then running it.</p>

<p>I have read <a href="http://stackoverflow.com/questions/7849539/comparison-method-violates-its-general-contract-java-7-only">Comparison method violates its general contract! Java 7 only</a> and realize that there is something wrong with my code that was ignored in previous versions of Java. However I cannot work out what is wrong with my code. The Collections.sort() generates the error.</p>

<p>My code is:</p>

<pre><code>   public Comparator sortBySmoothDays() {
    Comparator c = new Comparator() {
        public int compare(Object arg0, Object arg1) {
            Date date0 = ((PosObject)arg0).getDate();
            Date date1 = ((PosObject)arg1).getDate();

            double d1 = MyUtils.calcSmoothDays(date0, new Date());
            double d2 = MyUtils.calcSmoothDays(date1, new Date());
            if (d1 &gt;= d2) {
                return 1;
            }
            else {
                return -1;
            }   
        }
    };
    return c;
}


Comparator c = ComparatorUtils.getInstance().sortBySmoothDays();
Collections.sort(posList, c);
</code></pre>

<p>Can anyone help?  Thank you!</p>
