Reputation: 1226
I enumerated all available time zones on Android 12 by this code:
String[] ids = TimeZone.getAvailableIDs();
and found ids from "Etc/GMT+12" to "Etc/GMT-14" but in fact they equal "GMT-12" to "GMT+14". For example "Etc/GMT-7" equals "GMT+7".
Why Android uses negative names?
Upvotes: 1
Views: 592
Reputation: 219335
These names are offered by the IANA time zone database which underlies the time zone implementation on Android.
The database has the following comments referring to these names/definitions:
Be consistent with POSIX TZ settings in the Zone names, even though this is the opposite of what many people expect. POSIX has positive signs west of Greenwich, but many people expect positive signs east of Greenwich. For example, TZ='Etc/GMT+4' uses the abbreviation "-04" and corresponds to 4 hours behind UT (i.e. west of Greenwich) even though many people would expect it to mean 4 hours ahead of UT (i.e. east of Greenwich).
So IANA does it this way because POSIX does it this way. The POSIX spec for the environment variable TZ
is:
offset
...
The minutes (mm) and seconds (ss) are optional. The hour (hh) shall be required and may be a single digit. The offset following std shall be required. If no offset follows dst, the alternative time is assumed to be one hour ahead of standard time. One or more digits may be used; the value is always interpreted as a decimal number. The hour shall be between zero and 24, and the minutes (and seconds)-if present-between zero and 59. The result of using values outside of this range is unspecified. If preceded by a '-', the timezone shall be east of the Prime Meridian; otherwise, it shall be west (which may be indicated by an optional preceding '+' ).
(emphasis added by me)
For your amusement, note that POSIX is not self-consistent. Here is the POSIX spec for strftime
:
z
Replaced by the offset from UTC in the ISO 8601:2000 standard format ( +hhmm or -hhmm ), or by no characters if no timezone is determinable. For example, "-0430" means 4 hours 30 minutes behind UTC (west of Greenwich).
Upvotes: 1