title: Why number of days between 2 dates are not coming up correctly?
body: <p>I am currently trying to get the number of days between 2 dates.</p>
  
  <p><code>Date1 : 21-JAN-15</code></p>
  
  <p><code>Date2 : 23-JUL-15</code></p>
  
  <p>In my local eclipse tomcat server (in India), I am getting the number of days as: <code>183</code> with the following code:</p>
  
  <pre><code>Calendar cal1 = new GregorianCalendar();
  Calendar cal2 = new GregorianCalendar();
  
  Date date1 = new Date("21-JAN-15");
  Date date2 = new Date("23-JUL-15");
  
  cal1.setTime(date1);
  cal2.setTime(date2);
  
  System.out.println("Days= "+daysBetween(cal1.getTime(),cal2.getTime()));
  
  public int daysBetween(Date d1, Date d2){
           return (int)( (d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24));
   }
  </code></pre>
  
  <p>When I copy the same java file to a linux server and run the file there using <code>javac</code> and <code>java</code> commands, I get the difference as: 182, which is one day less.</p>
  
  <p>I have confirmed the default timezone of the linux server is EDT using the command: <code>date +%z</code></p>
  
  <p>I am very confused here. I do not have JODA library in my application and I can't use it. What changes do I need to make to get a uniform result both in my local environment and the linux server? Any help will be appreciated!</p>