title: Android Days between two dates
body: <p>I want to compare two dates for my Android application, but I got a really weird issue.</p>
  
  <p>For example:</p>
  
  <p>If I set the <code>back in the past</code> date to 127 days ago:</p>
  
  <pre><code>this.dateEvent = System.currentTimeMillis() - (127 * 24 * 3600 * 1000)
  </code></pre>
  
  <p>And then compare it to the current date (Days between)</p>
  
  <pre><code>    Calendar sDate = getDatePart(new Date(this.dateEvent));
      Calendar eDate = getDatePart(new Date(System.currentTimeMillis()));
  
      int daysBetween = 0;
      while (sDate.before(eDate))
      {
          sDate.add(Calendar.DAY_OF_MONTH, 1);
          daysBetween ++;
      }
  
      while (sDate.after(eDate))
      {
          eDate.add(Calendar.DAY_OF_MONTH, 1);
          daysBetween ++;
      }
  
      return daysBetween;
  </code></pre>
  
  <p>It will return 22 which is not at all what was expected.</p>
  
  <p>Did I make something wrong or is that an issue with the <code>Calendar</code> class ?</p>