title: Saving timestamps in Postgres based on Java dates
body: <p>I have a Postgres database with a table that contains a timestamp (<code>timeOfProcessing        TIMESTAMP</code>).</p>
  
  <p>I have a Java datetime value (<code>java.util.Date dateTime</code>) and want to store its value in that timestamp field (without time zone).</p>
  
  <p>When I do it using the query</p>
  
  <p><code>"INSERT INTO mytable(..., timeOfCreation, ...) VALUES(..., to_timestamp(" + Long.toString(dateTime.getTime()) + "),...)"</code></p>
  
  <p>and then read the saved value (<code>SELECT timeOfCreation FROM mytable</code>), they are different (<code>resultSet.getTimestamp(...).getTime()</code> is not equal to <code>dateTime.getTime()</code>).</p>
  
  <p>How do I need to change the insert statement in order for the datetime to be stored correctly?</p>