java - How to parse date to EEE MMM dd HH:mm:ss zzz yyyy format? -
i getting date database 2013-05-03 00:20:29.0. want parse date eee mmm dd hh:mm:ss zzz yyyy format, when parsing it, getting exception:
java.text.parseexception: unparseable date: "2013-05-03 00:20:29.0"
my code below:
string createddate = "2013-05-03 00:20:29.0"; simpledateformat format = new simpledateformat("eee mmm dd hh:mm:ss zzz yyyy"); date parsedate = format.parse(createddate);
your simpledateformat pattern not match createddate. format should be:
simpledateformat format = new simpledateformat("yyyy-mm-dd hh:mm:ss.s"); see javadoc
Comments
Post a Comment