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.
The database is using datetime type and the the timestamp is formated as "2014-07-23 09:50:14"
In the text file the timestamp is formated as "2014-07-23 09:51:25.877"
I am using a preparedstatement to save to the database.
preparedStatement.setTimestamp(2, new Timestamp(new Date().getTime()));
I am using a BufferedWriter to save to the text file.
bufferedWriter.write(new Timestamp(new Date().getTime())
How can i get the format to be the same so I can compare the timestamps?
By the way, I do not need millisecond precision, I just want the format to be the same.