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

c# - Sort XmlNodeList with a specific Node value -

Android Java.Lang.RuntimeException : Unable to start activity Component Info -

actionscript 3 - Equivalent to moveReceived in ElectroServer 5 -