title: Java Best Practice for Date Manipulation/Storage for Geographically Diverse Users
body: <p>I have read all of the other Q/A about Date Manipulation, but none of them seems to deliver a satisfactory answer to my concern.</p>
  
  <p>I have a project with geographically diverse users which uses <code>Date</code> in some of its classes and data. The thing is that I am looking for an efficient way to manipulate the Dates for the different users in their respective timezone, most of the answers suggest using <a href="http://www.joda.org/joda-time/" rel="noreferrer">Joda</a> library for <code>Date</code> manipulation, which quite don't understand yet because I still have not found any operation you cannot do with traditional Java, so if someone can explain what can I do with <a href="http://www.joda.org/joda-time/" rel="noreferrer">Joda</a> that can't be done with traditional Java, then I may consider using it.</p>
  
  <p>I finally came to the approach of using <code>System.currentTimeMillis()</code> to save my dates into the database (any database). This would avoid me to worry about what timezone is using the database to store the dates. If I want to query the database for an specific date or range of dates, I would perform the queries using the <code>long</code> value of the <code>Date</code> I want to query:</p>
  
  <pre><code>SELECT * FROM table1 WHERE date1&gt;=1476653369000
  </code></pre>
  
  <p>And when retrieving a <code>ResultSet</code> I would then format the <code>long</code> value retrieved from database to a readable <code>Date</code> using the timezone of the user requesting the data.</p>
  
  <pre><code>Calendar cal = Calendar.getInstance();
  cal.setTimeInMillis(resultSet.getLong(1));
  cal.setTimeZone(TimeZone.getTimeZone("Asia/Calcutta"));
  Date myDate = cal.getTime();
  </code></pre>
  
  <p>According to some opinions I have read, some people say emphatically that storing <code>System.currentTimeMillis()</code> is definitely not the best practice, nevertheless, for some reason they all miss to say <strong>WHY</strong> it is not recommendable. Am I missing something? Does this cause a performance issue for the conversions <code>Long-&gt;Date</code>/<code>Date-&gt;Long</code>? Is there any use case that cannot be accomplished when using <code>Long</code> instead <code>Date</code> in database? Can someone post a rationale explanation about this?</p>
  
  <p>In the other hand, assuming that I keep using <code>Date</code> values to store dates in database, is there a way to avoid worrying about time-zones while handling database <code>Date</code>?</p>
  
  <p>Thanks in advance.</p>