0

In Android

Timezone.getAvailableIds();

returns only 580 ids.

In Java (both are same version 1.7)

Timezone.getAvailableIds()

returns 623 ids.

Some of the missing IDs are

IST

PST

ECT

JST

Any help on this?

  • 1
    What do you mean with "help on this"? How is it causing problems and how are you using this timezones? – OH GOD SPIDERS Oct 17 '17 at 09:52
  • Yes.. I'm using TimeZone.getTimeZone(userTZ); to get the Timezone and to format the time. If the userTZ is any of the missing Ids, it returns GMT, by default. It causes the Time issue where ever I show the time. – Vignesh Thillai Oct 17 '17 at 09:59
  • Those short names (IST, PST and others) are [ambiguous and not standard](https://stackoverflow.com/a/18407231/7605325), and some are supported for retrocompatibility reasons. e.g. IST can be India Standard Time, Irish Standard Time or Israel Standard Time. It's much better to allow only [IANA timezones names](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) (always in the format `Region/City`, like `Asia/Kolkata` or `Europe/Berlin`) –  Oct 17 '17 at 10:48
  • @Hugo Thank you for your answer! – Vignesh Thillai Oct 20 '17 at 07:20

1 Answers1

1

For compatibility with JDK 1.1.x, some other three-letter time zone IDs (such as "PST", "CTT", "AST") are also supported.

Notice the word "some", meaning that in Android not all three-letter time zone IDs are supported. This is why you get only 580 IDs instead of 623. The supported time zone IDs would depend on the SDK version you're using.

Also, note that this way of representation is deprecated:

However, their use is deprecated because the same abbreviation is often used for multiple time zones (for example, "CST" could be U.S. "Central Standard Time" and "China Standard Time"), and the Java platform can then only recognize one of them.

Reference: https://developer.android.com/reference/java/util/TimeZone.html

I hope this answers your question.

Sergey Emeliyanov
  • 5,158
  • 6
  • 29
  • 52