title: How to insert current date and time in a database using SQL?
body: <p>I used the following code, but the DateTime field in SQL is represented as:</p>
  
  <pre><code>2005-04-08 00:00:00
  </code></pre>
  
  <p>I want to have the time too. what should I change?</p>
  
  <p>Here is my code below:</p>
  
  <pre><code>// Get the system date and time.
  java.util.Date utilDate = new Date();
  // Convert it to java.sql.Date
  java.sql.Date date = new java.sql.Date(utilDate.getTime());
  ...
  ...
  ...
  PreparedStatement stmt = connection.prepareStatement(sql);
  stmt.setDate(1, date);
  </code></pre>