title: JDBC converting dates to UTC
body: <p>I have some code inserting a timestamp in a Postgres table. Here is the definition of the field where the timestamp is inserted:</p>
  
  <pre><code>datelast timestamp without time zone
  </code></pre>
  
  <p>I use this Java code to update data in the field:</p>
  
  <pre><code>PreparedStatement sqlStatement = connection.prepareStatement(
          "UPDATE datetest SET datelast = ? WHERE id = ? ");
      sqlStatement.setTimestamp(1, new java.sql.Timestamp((new Date()).getTime()));
      sqlStatement.setInt(2, 1);
      sqlStatement.executeUpdate();
  </code></pre>
  
  <p>My problem is that it inserts the UTC timestamp instead of my local timestamp (eastern time). So when I check the data in my table, I see "2010-02-08 19:07:21.261" instead of "2010-02-08 14:07:21.261".</p>
  
  <p>Actually, I had this code running has I would like to on an old server, but after migrating the code, I got that problem. The problem is not whit Postgres because I still use the same DB. I also checked the OS timezone and they are the same. I also tried a "System.out.println("TZ = " + TimeZone.getDefault());" and I get the same timezone on both servers. So my conclusion is that the JDBC driver is converting the date in UTC before inserting it in the table.</p>
  
  <p>Can anyone help me to figure out why the timestamp is converted?</p>
  
  <p>Thanks</p>