Seth Nelson
Seth Nelson

Reputation: 2608

TimeFormatException while using time.parse()?

I'm trying to persistently store time data. I write the time to the preferences as a string passing it the time.toString(), and then restore it from the string by using the time.parse(String) method. However, I find that the parse method is throwing a TimeFormatException, specifically:

android.util.TimeFormatException: Unexpected character 0x41 at pos=15. Expected Z

I use logcat to view the string i am passing to parse, and it looks normal:

20110321T021030America/Detroit(1,79,-14400,1,1300687830)

Can anyone figure out why this is? Does the "expected Z" mean the letter Z specifically, or does it mean any integer, or what? And why is this happening? It seems like parsing a Time's toString() would be the easiest way to ensure that there ISN'T a timeformatexception, and yet I am still getting one.

Upvotes: 0

Views: 411

Answers (2)

Vinayak Bevinakatti
Vinayak Bevinakatti

Reputation: 40503

The problem with parsing the date format which has been passed to time.parse(); function Please refer the link to rectify you problem Custom Date and Time Format Strings

Upvotes: 0

Philio
Philio

Reputation: 4185

It probably just doesn't recognise the format. You could use time.getTime() to get the unix time value instead, this might be easier to use.

Upvotes: 1

Related Questions