I am trying to format the current datetime and then save it to the database using sleep mode. I got it to save using the default date format, that is:
Date date = new Date(); hibernateObject.setDate(date); hibernateObject.save(date);
I found a way to format it, but it is really messy and doesn't seem to work:
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);
java hibernate
ThreaT Aug 21 '13 at 18:12 2013-08-21 18:12
source share