java.util.Locale has an empty first item

后端 未结 3 757
悲哀的现实
悲哀的现实 2020-12-19 18:11

I am trying to get all the locales from the JVM to populate a Country drop down. The first item is an empty not null object. It isn\'t null because I am using a TreeMap Coll

3条回答
  •  甜味超标
    2020-12-19 18:36

    The locale in question is none other than Locale.ROOT. locale == Locale.ROOT on my end, and I assume that the same will be true for you.

    Why does Locale.ROOT exist? According to http://www.oracle.com/technetwork/java/javase/java8locales-2095355.html:

    The default “JRE” locale provider’s resources for the Locale.ROOT locale are used if none of the specified locale providers support the requested locale. For example, if only “CLDR” is specified in “java.locale.providers” system property, Collator works as if requested for the ROOT locale because “CLDR” locale provider does not provide Collator locale data. Specifying “CLDR,JRE” supplements the “JRE” locale provider’s Collator functionality, as well as preferring “CLDR” locale provider’s other locale data to “JRE”’s ones.

提交回复
热议问题