What is easiest way to compare two dates
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2592501/compare-dates-in-java">Compare dates in java</a>  </p>
</blockquote>



<p>I am getting two dates from server in yyyy-MM-dd format. I have to compare between these two dates. I used compareTo() method to compare two dates. what is more easier way to compare two dates assuming my server will always return not null value in yyyy-MM-dd format?</p>

<p>Define the method</p>

<pre><code>void compareTwoDates(String startDate, String endDate){
        switch(startDate.compareTo(endDate)){
            case -1:
                //START DATE IS BIGGER THAN END DATE
                System.out.println(endDate+" IS BIGGER THAN "+startDate);
                break;
            case 0:
                //BOTH DATE ARE SAME
                System.out.println("SAME DATE");
                break;
            case 1:
                //END DATE IS BIGGER
                System.out.println(startDate+" IS BIGGER THAN "+endDate);
                break;
        }
    }
</code></pre>

<p>call the method using following way</p>

<pre><code>compareTwoDates("2012-05-06", "2012-04-08");
compareTwoDates("2012-04-09", "2012-04-09");
compareTwoDates("2012-04-09", "2011-05-10");
</code></pre>
