title: Format DateTime
body: <p>I'm trying to format the current <code>datetime</code> and then save it to a database using hibernate. I got it to save using the default date format, i.e.:</p>
  
  <pre><code>Date date = new Date();
  hibernateObject.setDate(date);
  hibernateObject.save(date);
  </code></pre>
  
  <p>I've found a way to format it but it's really untidy and doesn't seem to work:</p>
  
  <pre><code>Date finalDate = null;
  try {
      Date date = new Date();
      DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
      String sDate = df.format(date);
      finalDate = df.parse(sDate);
  } catch (ParseException pe) {
      System.out.println("ParserException while attempting to establish date");
  }
  hibernateObject.setDate(date);
  hibernateObject.save(date);
  </code></pre>