How to insert current time in MySQL using Java -
I need to enter the current date and time (milliseconds) in MySQL. I have done the following:
long = System.currentTimeMillis (); Java.sql.Timestamp timestamp = new java.sql.Timestamp (time); System.out.println ("Time in millisecond:" + timestamp); And I found time in milliseconds (eg 2013-03-21 00: 08: 33.523). However, I need to put this information into the MySQL database, I tried the following using the created condition prepStmt.setTimestamp (2, timestamp) ; But the time is inserted without milliseconds (e.g., 2013-03-21 00:08:33).
How can I incorporate time with milliseconds?
Edit: is the type of code in the database, DATETIME .
Comments
Post a Comment