title: Subtract two dates in Java
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1555262/calculating-the-difference-between-two-java-date-instances">Calculating the Difference Between Two Java Date Instances</a>  </p>
  </blockquote>
  
  
  
  <p>I know this might be a duplicate thread. But I am trying to figure out a way to compute the difference between two dates. From jquery the date string is in the format <code>'yyyy-mm-dd'</code>. I read this as a String and converted to java Date like this</p>
  
  <pre><code>Date d1 = new SimpleDateFormat("yyyy-M-dd").parse((String) request.getParameter(date1));
  Date d2 = new SimpleDateFormat("yyyy-M-dd").parse((String) request.getParameter(date2));
  </code></pre>
  
  <p>I want to compute the difference in the number of days between these two dates.</p>
  
  <p><strong>Note:</strong> I cannot use third party API's as those need to reviewed.</p>