I am allowing users on my web app to schedule events based on time zones of their choice.
I want to present a good list of time zones to the end user and then convert it easily to java.util.TimeZone
object at the server end.
String[] TimeZone.getAvailableIds()
is something I could use, but the issue is that it prints about 585 time zone ids.
What is the best way to present to the user a brief list of time zones (like a Windows box would for time zone settings) and easily convert to TimeZone object at server end using its id?
You can explicitly set a default time zone on the command line by using the Java system property called user. timezone . This bypasses the settings in the Windows operating system and can be a workaround.
If you cannot change the OS or the JVM timezone, you can still convert a Java Date/Time or Timestamp to a specific time zone using the following two JDBC methods: PreparedStatement#setTimestamp(int parameterIndex, Timestamp x, Calendar cal) – to convert the timestamp that goes to the database.
ECT - Europe/Paris. IET - America/Indiana/Indianapolis. IST - Asia/Kolkata. JST - Asia/Tokyo.
The list of timezones is very application and locale specific. Only you know what zones are most applicable to your users. We actually have different lists for different regions.
Here is our list for US users for your reference,
"Pacific/Midway", "US/Hawaii", "US/Alaska", "US/Pacific", "America/Tijuana", "US/Arizona", "America/Chihuahua", "US/Mountain", "America/Guatemala", "US/Central", "America/Mexico_City", "Canada/Saskatchewan", "America/Bogota", "US/Eastern", "US/East-Indiana", "Canada/Eastern", "America/Caracas", "America/Manaus", "America/Santiago", "Canada/Newfoundland", "Brazil/East", "America/Buenos_Aires", "America/Godthab", "America/Montevideo", "Atlantic/South_Georgia", "Atlantic/Azores", "Atlantic/Cape_Verde", "Africa/Casablanca", "Europe/London", "Europe/Berlin", "Europe/Belgrade", "Europe/Brussels", "Europe/Warsaw", "Africa/Algiers", "Asia/Amman", "Europe/Athens", "Asia/Beirut", "Africa/Cairo", "Africa/Harare", "Europe/Helsinki", "Asia/Jerusalem", "Europe/Minsk", "Africa/Windhoek", "Asia/Baghdad", "Asia/Kuwait", "Europe/Moscow", "Africa/Nairobi", "Asia/Tbilisi", "Asia/Tehran", "Asia/Muscat", "Asia/Baku", "Asia/Yerevan", "Asia/Kabul", "Asia/Yekaterinburg", "Asia/Karachi", "Asia/Calcutta", "Asia/Colombo", "Asia/Katmandu", "Asia/Novosibirsk", "Asia/Dhaka", "Asia/Rangoon", "Asia/Bangkok", "Asia/Krasnoyarsk", "Asia/Hong_Kong", "Asia/Irkutsk", "Asia/Kuala_Lumpur", "Australia/Perth", "Asia/Taipei", "Asia/Tokyo", "Asia/Seoul", "Asia/Yakutsk", "Australia/Adelaide", "Australia/Darwin", "Australia/Brisbane", "Australia/Sydney", "Pacific/Guam", "Australia/Hobart", "Asia/Vladivostok", "Asia/Magadan", "Pacific/Auckland", "Pacific/Fiji", "Pacific/Tongatapu",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With