开发者

J2ME Get current time zone

I have a j2me application and it needs to get the name of the current timezone and send it off to the server.

However, the only format that I seem to be able to get the phone to give me is "GMT-5:00". What I want the application to do is return the timezone's name (EST, PST, etc.)

I iterated over the string[] returned by TimeZone.getAvailableIds() and it has a list of all the time zones in the format that I want them in. (EST, CST, 'Pheonix, USA', 'Europe/Samara', etc.)

Any ideas on how to get the开发者_运维技巧 timezone's name instead of as an offset from GMT+0? Thanks in advance.


TimeZone.getID() is what you're looking for; it should return one of the values returned by TimeZone.getAvailableIDs().


you can make an array in which you'll put all your time zone ids. then just add 12 to the returned time zone offset and you can use that as an index for calling time zone names from your array.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜