赞
踩
Locale对象表示了一个特定的地理,政治或文化区域。需要使用到Locale执行其任务的操作称为区域设置敏感,并使用Locale为用户定制信息。
例如显示一个数字就是一个区域设置敏感的操作–该数字应根据用户所在国家,地区或文化的习俗和惯例进行格式化。
1.在日期格式里:
val format = SimpleDateFormat("MM-dd HH: mm", Locale.getDefault())
2.在语言设置时,需要对返回的字符串进行大写/小写操作,这时候在toUpperCase()使用Locale.getDefault(),他便会根据语言环境自行转换
- textReplyType.text=setReplyTypeTextUP(data.getAnswerMsgType().toString())?
- .toUpperCase(Locale.getDefault())
- Locale.getDefault().getLanguage() ---> en
- Locale.getDefault().getISO3Language() ---> eng
- Locale.getDefault().getCountry() ---> US
- Locale.getDefault().getISO3Country() ---> USA
- Locale.getDefault().getDisplayCountry() ---> United States
- Locale.getDefault().getDisplayName() ---> English (United States)
- Locale.getDefault().toString() ---> en_US
- Locale.getDefault().getDisplayLanguage()---> English
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。