javalocale

What is the different from Locale.ITALY and Locale.ITALIAN


What is the difference between a Locale country and language such as Locale.ITALY and Locale.ITALIAN? Where can I find all these differences for other locales? When should I use each one?

And is it possible to develop our required locale? How?


Solution

  • Locale.ITALIAN sets only Italian language, country is left unspecified. Locale.ITALY sets both Italian as language and Italy as country.

    It depends on classes that use Locale how they will inteprete this combination. Eg DateFormat API says to format a date for a different Locale, specify it in the call to getDateInstance(). but it does not say how exactly language and country will be interpreted. From my experience DateFormat (and other JDK classes except ResourceBundle) use only language part and ignore country. That is you may create DateFormat for it_IT or it_US or it_UK locales the DateFormat output will be the same