What strategy do other webapps use to generate a nicely formatted list of timezones for user preferences?
I tried just getting all the time zones, but the list is long and not exactly formatted well for a user.
Just want to know how other people are doing this.
The following code snippet
will print formatted time zones like:
You might want to add filtering for different offsets and/or time zones given from
zone.getDisplayName(zone.useDaylightTime(), TimeZone.SHORT)
.An easy way is to put the time zones IDs in the list instead of the time zones themselves.
TimeZone.getAvailableIDs()
returns values such as GMT, Europe/Paris, America/New_York...