问题
I'm having trouble mapping joda time zones to windows time zones.
I use the xml of CLDR mappings, and it works for most of the translations.
nevertheless, it doesn't have values for several joda time zones:
America/Indiana/Indianapolis, BST, Australia/Victoria, Universal, Australia/NSW, America/Fort_Wayne, Africa/Asmara, America/Kentucky/Louisville, Asia/Kashgar, US/Pacific, Australia/West, Australia/Queensland, Australia/South, US/Eastern, US/Central, US/Arizona, Australia/Tasmania, NZ, US/Mountain, Australia/Eucla, GMT, Japan, CAT, Etc/GMT+0, CST, PST, EST, Australia/Canberra, Mexico/General, Israel, Canada/Eastern, Etc/GMT+9, Canada/Central, Australia/North
Where can I find the mapping between these joda timezones to windows timezones?
回答1:
Using pure CLDR data:
Check for the zone in the /common/bcp47/timezone.xml file.
If it's not the first entry in the
aliasfield, then use the first entry. Example:<type name="aumel" description="Melbourne, Australia" alias="Australia/Melbourne Australia/Victoria"/>You can see
Australia/Victoriaas the second item, so it is an alias toAustralia/Melbourne. Note that CLDR's canonical zones are not exactly matched to TZDB's definition of canonical, so use these CLDR mappings - not thelinkentries from tzdb.Now check the /common/supplemental/windowsZones.xml file. Example:
<mapZone other="AUS Eastern Standard Time" territory="AU" type="Australia/Sydney Australia/Melbourne"/>The
typefield contains one or more tzdb zones. Theotherfield contains the corresponding Windows zone.Be aware that not all tzdb zones have a valid corresponding Windows zone, and some are not perfect mappings.
Example of imperfect mapping:
America/Havana=>Eastern Standard Time- DST transition days align, but Cuba transitions at midnight instead of 2 AM
Example of unmappable zone:
Australia/Lord_Howe- Exists in timezone.xml, but not in windowsZones.xml.
- There is currently no Windows time zone entry for this location.
You have a few items in your list (
BST,CAT,CST,PST) that are not valid tzdb zones, even by Joda-Time's list. These could be abbreviations or rule names, but they are not zone identifiers.
来源:https://stackoverflow.com/questions/31561768/mapping-joda-timezone-to-windows-timezone-for-example-in-c