简体   繁体   中英

How to convert Java Timestamp to mySQL datetime function

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 .

您无需在mysql中将时间戳记作为String插入,只需将其视为java.sql.Timestamp并使用PreparedStatement正确设置值即可

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM