有什么不同于Locale.ITALY和Locale.ITALIAN [英] What is the different from Locale.ITALY and Locale.ITALIAN

查看:144
本文介绍了有什么不同于Locale.ITALY和Locale.ITALIAN的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Locale国家和语言(例如

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?

推荐答案

Locale.ITALIAN仅设置意大利语,国家/地区未指定. Locale.ITALY将意大利语设置为语言,将意大利设置为国家.

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

这取决于使用Locale的类如何解释此组合.例如,DateFormat API说要为其他语言环境设置日期格式,请在对getDateInstance()的调用中指定日期.但未说明语言和国家/地区的确切解释方式.根据我的经验,DateFormat(以及ResourceBundle以外的其他JDK类)仅使用语言部分,而忽略国家/地区.也就是说,您可以为it_IT或it_US或it_UK语言环境创建DateFormat,DateFormat输出将相同

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

这篇关于有什么不同于Locale.ITALY和Locale.ITALIAN的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆