title: JDBC/MySQL: Save timestamp always using UTC
body: <p>I would like to save a timestamp to the database without being converted to the local timezone by the jdbc driver. Currently only MySQL and PostgreSQL are important for me but i would appreciate if there is a database independent solution.</p>
  
  <p>Example:</p>
  
  <pre><code>// i want that to be saved as 1970-01-01 00:00:00
  TimeStamp ts = new java.sql.Timestamp(0);
  
  // gets transformed to local time by jdbc driver (in my case to 1970-01-01 01:00:00)
  st.setTimestamp(0, new java.sql.Timestamp(0));
  
  // only works using postgres (mysql connector seems to ignore the calendar)
  // postgres =&gt; 1970-01-01 00:00:00
  // mysql =&gt; 1970-01-01 01:00:0
  Calendar calutc = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
  st.setTimestamp(0, new java.sql.Timestamp(0), utccal);
  </code></pre>
  
  <p>I already tried to calculate a timestamp value that get transformed to the correct value (for example -3600000 => 1970-01-01 00:00:00 in my time zone) but this doesn't work on postgres on dates near the day light saving time changes.</p>