ユーザーの TimeZone を取得しようとしています。
このために、有効な ISO 国コードである国コードがあります。これらのコードは、ISO-3166 で定義されている大文字の 2 文字のコードです。これらのコードの完全なリストは、http: //www.chemie.fu-berlin.de/diverse/doc/ISO_3166.htmlなどの多くのサイトで見つけることができます 。
答えは「いいえ、なぜならそれは多対多の関係だからです... アメリカのような国には多くのタイムゾーンが存在する可能性があります...」. それが問題です...
私は次のようなものを試しました:
//CountryEnum contains ISO_3166 values (http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html)
//List all country to test timezone:
for (int i = 0; i < CountryEnum.values().length; i++) {
String isoCountryCode = CountryEnum.values()[i].name();// Get the iso country code
Locale locale = new Locale(isoCountryCode);// Build a country specific locale
Calendar calendar = Calendar.getInstance(locale);// Build a calendar with the specific locale
String timeZone = calendar.getTimeZone().getDisplayName();// Build a timeZone with the calendar
System.out.println("LOCALE : "+locale+" / COUNTRY: "+isoCountryCode+" / TIMEZONE: "+timeZone);
}
ただし、常にサーバーの TimeZone を返します...
何か案は ?