views:

420

answers:

2

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.

+1  A: 

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

funkybro
Doesn't work. That method returns the following:GMT-05:00
Null
It must vary by device then, which handset are you using?
funkybro
I'm developing on a Motorola i290
Null
A: 

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.

Aaron