java - Error while parsing a time string -


this question has answer here:

i trying parse time strings this:

string time_string = "10:00 am"; simpledateformat format = new simpledateformat("hh:mm a"); date date = null; try {     date = format.parse(time_string);     // 'date' } catch (parseexception e) {     log.w("time", e.tostring()); } 

but parser failing exception:

java.text.parseexception: unparseable date: "10:00 am"

what doing wrong?

the am/pm marker may not match of default locale try

simpledateformat format = new simpledateformat("hh:mm a", locale.english); 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -