What is the difference between creating a locale for en-US and en_US?

后端 未结 4 1470
暗喜
暗喜 2020-12-08 18:53

I have all my ResourceBundle values in a table and formatted as per requirement. I have to change the languages on the website based on user selection in a drop

4条回答
  •  生来不讨喜
    2020-12-08 19:33

    As of Java8, initializing the locale should be done using the language tag en-US. Locale.forLanguageTag("en-US").toString(); returns the output: en_US

    Where as Locale.forLanguageTag("en_US") does not create the required locale. It will default to the system locale. Locale.forLanguageTag("en_US").toString() returns null

提交回复
热议问题