android - Convert date into "17. December 2015" Format -
i getting date in form of "20150119" , want convert format like: "19. january 2015" .
how can convert date in such format.
i tried below code:
private void convertdate() { string m_date = "20150119"; simpledateformat originalformat = new simpledateformat("yyyy.mm.dd"); try { date date = originalformat.parse(m_date.tostring()); log.e("date is====", date.tolocalestring()); } catch (parseexception e) { // todo auto-generated catch block e.printstacktrace(); } } but giving me error:
java.text.parseexception: unparseable date: "20150119" (at offset 8)
you need specify 2 formats: 1 parse input, 1 format output.
the error occurs because string trying parse not match format specified in
originalformat: 1 needs besimpledateformat originalformat = new simpledateformat("yyyymmdd");if want parse strings of format
string m_date = "20150119";. parsing string format givedate:date date = originalformat.parse(m_date);then may use format output
date:simpledateformat outputformat = new simpledateformat("dd. mmmm yyyy"); system.out.println("date: " + outputformat.format(date));
Comments
Post a Comment