java - date is saving in different format when saving to database -


iam saving date in below format eee mmm dd hh:mm:ss z yyyy, saving in format 2013-05-03 00:38:20.0. when print same date on console before saving database, expected info: fri may 03 00:38:20 ist 2013

please can explain why saving above mentioned.

below code:

date = new date(); string datetimestr = now.tostring(); simpledateformat format = new simpledateformat( "eee mmm dd hh:mm:ss z yyyy"); date parsedate = format.parse(datetimestr); 

datebase column

date_order_created date 

from here
following code formats date , time according pattern string passed simpledateformat constructor. string returned format method contains formatted date , time displayed.

date today; string output; simpledateformat formatter;  formatter = new simpledateformat(pattern, currentlocale); today = new date(); output = formatter.format(today); system.out.println(pattern + " " + output); following table shows output generated previous code ex pattern              output eee, mmm d, ''yy    tue, jun 30, '09 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -