0

My code uses Java.sql.Timestamp to store an update date. I want to take that date and store it into a mySQL datetime object. My problem is that the Java.util.Timestamp returns a date in the format of 2013-12-09 00:00:00.00 but the mySQL colunmn wants the format in 2013-12-09 00:00:00. So it looks like I need to trim off the .00 of the java.sql.Timestamp.

1 Answer 1

1

You don't need to insert timestamp in mysql as String, just treat it as java.sql.Timestamp and use PreparedStatement to set the value properly

Sign up to request clarification or add additional context in comments.

1 Comment

I do just add the timestamp and it kicks this error com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect datetime value: '' for column 'update_date' at row 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.