开发者

TimeFormatException while using time.parse()?

开发者 https://www.devze.com 2023-02-18 12:02 出处:网络
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.

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 the开发者_运维问答re ISN'T a timeformatexception, and yet I am still getting one.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号