title: JPA Date and Timezone confusion
body: <p>I'm having a problem reading dates from a database using JPA. I'm using EclipseLink and PostgreSQL</p>
  
  <p>I've populated my database from a CSV file, witch had dates as strings (in this format: <code>6/30/2009-23:59:56</code>). I used the following snipet to convert it to a Date object:</p>
  
  <pre><code>public static Date parseDate(String s){
      DateFormat formatter = new SimpleDateFormat("d/M/yyyy-k:m:s");
      try {
          return new Date( ((java.util.Date)formatter.parse(s)).getTime() );
      } catch (ParseException ex) {
          Logger.getLogger(Type.class.getName()).log(Level.SEVERE, null, ex);
          return null;
      }
  }
  </code></pre>
  
  <p>The date is correctly converted and stored in the database as expected. Here is how i map the Date object to the database:</p>
  
  <pre><code>@Column(name="data_ts", nullable=false)
  @Temporal(TemporalType.TIMESTAMP)
  private Date dataTs;
  </code></pre>
  
  <p>The problem seems to happen when i try to read the Date from the database to use it in a chart(Highcharts). The record with that same timestamp above get read as:</p>
  
  <p><code>Mon Jun 06 23:59:56 BRT 2011</code> and it's timestamp as <code>1307415596000</code></p>
  
  <p>Note that it is in Brazilian Time(+3h), so the timestamp (that is calculated from GMT) is 3 hours shifted. Once ploted, the timestamp turns to point to <code>07/06/2011 02:59:56</code></p>
  
  <p>Here's an example:</p>
  
  <pre><code>List&lt;TimedataEnt&gt; timeData = currentWellsite.getTimeData();
  String debug = timeData.get(timeData.size()-1).getDataTs().toString() + "&gt;&gt;&gt;" + timeData.get(timeData.size()-1).getDataTs().getTime();
  </code></pre>
  
  <p>where <em>currentWellsite</em> is and JPA Entity, and <code>getDataTs()</code> returns a java.util.Date object. 
  The string turns out to be <code>"Tue Jun 30 23:59:56 BRT 2009&gt;&gt;&gt;1246417196000"</code></p>
  
  <p>How do I tell JPA not to convert the timestamp read from the database?</p>