java - How to insert current date and time in a database using SQL? -


I used the following code, but the date range is shown in SQL as:

  2005-04-08 00:00:00  

I should also have time what should I change?

Here my code is given:

  // Get the system date and time Java.util.Date Usage date = new date (); // Change it to java.sql.Date. Java.sql.Date date = new java.sql.Date (useDate.getTime ()); ... ... ... created location stmt = connection.prepareStatement (SQL); Stmt.setDate (1, date);  

Use setTimestamp instead of setDate < Try , because the timestamp is the preferred format for timing data and .


Comments

Popular posts from this blog

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -