开发者

android problem with SimpleDateFormat TimeZone

开发者 https://www.devze.com 2023-02-28 03:27 出处:网络
Let\'s开发者_运维百科 consider this code sample: DateFormat sdf = SimpleDateFormat.getTimeInstance(SimpleDateFormat.LONG,

Let's开发者_运维百科 consider this code sample:

DateFormat sdf = SimpleDateFormat.getTimeInstance(SimpleDateFormat.LONG, 
                    new Locale("ru", "RU"));
                 Date date = sdf.parse("8:13:05 PDT");

When I run this code on my desktop(java 1.6) all passes well, however on android devices I get exception, I think this is due to locale TimeZone:

java.text.ParseException: Unparseable date: 8:13:05 PDT

Why?


I don't believe UNIX can parse the PDT timezone. I'm having the same issue. It can handle PST & PST8PDT, but not PDT. I believe the recommended solution is to use PST8PDT instead.

0

精彩评论

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