title: Convert String to Postgres Timestamp and back
body: <p><strong>Part 1:</strong></p>
  
  <p>I have a file which contains date as string in the following format: <code>2006-02-16T21:36:32.000+0000</code></p>
  
  <p>I need to write this value to Postgres in a column which is of type <code>Timestamp</code>. How do I go about doing this in Java?</p>
  
  <p><strong>Part 2:</strong></p>
  
  <p>I need to read the value saved in Part 1 from Postgres, and convert it to a string of the following format <code>"2006-02-16T21:36:32.000+0000"</code></p>
  
  <hr>
  
  <p>This is what I have tried: </p>
  
  <p><code>Timestamp lastSyncDate = Timestamp.valueOf(2006-02-16T21:36:32.000+0000)</code></p>
  
  <p>When I try to write it to postgres, it gives me the following error:</p>
  
  <p><code>java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]</code></p>