开发者

Converting date in string to specified locale on Android

I have this date in string:

"2011-08-28 08:30:00 +0000"

I want this to convert to a java.util.Date in hungarian Locale, so I try to use this formatter:

DateFormat currentDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z", new Locale("hu"));

I am expecting that with currentDateFormat.parse I get "2011-08-28 10:30:00" as date (Hungary is GMT+2) but it is still "2011-08-28 08:30:00". I've tried to use setTimeZone(TimeZone.getDefault()) but didn't help.

开发者_C百科

Any ideas?


Android only uses UTC, no more GMT.

The problem is the date you have there is not clearly UTC and Android doesn't know what to do with it so it's default behavior is to just assume your date is in the current time zone.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜