title: Date to Day conversion in Java
body: <p>I am  able to convert date to days using the below code. </p>
  
  <pre><code> SimpleDateFormat sfd = new SimpleDateFormat("yyyy-MM-dd");
   String s1 = sfd.format(dateObj);
   String a1 [] = s1.split("-");
   int year = Integer.parseInt(a1[0].toString());
   int month = Integer.parseInt(a1[1])-1;
   int day = Integer.parseInt((a1[2]));
  
   Calendar c1 = Calendar.getInstance();
   c1.set(year,month,day);
  
   days = c1.getTime().getTime()/(24*60*60*1000);
  </code></pre>
  
  <p>The above code works accurately in my system which is windows with timezone GMT +5.30.</p>
  
  <p>However the same code in EST or Pacific timezone adds a day by 1 to final result when the time is 20.00 in the system. </p>
  
  <p>What could be the issue ?</p>
  
  <p>Do we need to set Timezone explicitly in the code ?</p>
  
  <p>input dates does not hold any time stamp .. 
  is it correct to store in <code>java.util.Date</code> instead of <code>java.sql.Date</code>?</p>