title: Timestamp in database has different format from timestamp in textfile
body: <p>I am saving current time in my application to a MYSQL database as a timestamp, as a backup I will save the date to a text file. However, the format of the timestames is not the same, I want them to be the same because i need to be abel to compare them. </p>
  
  <p>The database is using datetime type and the the timestamp is formated as "2014-07-23 09:50:14"</p>
  
  <p>In the text file the timestamp is formated as "2014-07-23 09:51:25.877"</p>
  
  <p>I am using a preparedstatement to save to the database.</p>
  
  <pre><code>preparedStatement.setTimestamp(2, new Timestamp(new Date().getTime()));
  </code></pre>
  
  <p>I am using a BufferedWriter to save to the text file. </p>
  
  <pre><code>bufferedWriter.write(new Timestamp(new Date().getTime())
  </code></pre>
  
  <p>How can i get the format to be the same so I can compare the timestamps?</p>
  
  <p>By the way, I do not need millisecond precision, I just want the format to be the same. </p>