this question has answer here:
- java date format yyyy-mm-dd.hh.mm.ss.ms 3 answers
i have date string follows:
2015-12-24 08:06:44
now have parse function:
public static string parsedate(string date) { date olddate = null; try { system.out.println("unparsed: "+date); dateformat oldformat = new simpledateformat("yyyy-mm-dd hh:mm:ss"); olddate = oldformat.parse(date); system.out.println("old date parsed: "+olddate); dateformat newformat = new simpledateformat("yyyy-mm-dd", locale.english); date result = newformat.parse(olddate.tostring()); return result.tostring(); } catch (exception e) { e.printstacktrace(); } return null; }
the first system.out gives me:
unparsed: 2015-12-24 08:06:44
the second one:
sat jan 24 08:06:44 gmt+05:30 2015
where second 1 have mentioned date format as:
new simpledateformat("yyyy-mm-dd hh:mm:ss");
please advise on whats wrong here
i want month , day input string - desired dec 24
above sample date string.
its mm
month not mm
.
dateformat oldformat = new simpledateformat("yyyy-mm-dd hh:mm:ss a");
Comments
Post a Comment