Locale deserialize 'zh-hant_CN'
See original GitHub issuezh-hant_CN
will convert to zh_HANT_cn
Locale include (language, country, variant), Locale.toString() use ‘_’ to split then {language}_{country}_({variant}_# | #){script}-{extensions}
but Jackson deserialize Locale use ‘-’ or ‘_’ : ( code: FromStringDeserializer.Std._deserialize
zh-Hant Chinese, in traditional script [Mark_Davis][Mark_Davis_2]
zh-Hant-CN PRC Mainland Chinese in traditional script [Mark_Davis][Mark_Davis_2]
zh-Hant-HK Hong Kong Chinese in traditional script [Mark_Davis][Mark_Davis_2]
zh-Hant-MO Macao Chinese in traditional script [Mark_Davis][Mark_Davis_2]
zh-Hant-SG Singapore Chinese in traditional script [Mark_Davis][Mark_Davis_2]
zh-Hant-TW Taiwan Chinese in traditional script [Mark_Davis][Mark_Davis_2]
Example of a Lookup Fallback Pattern
Range to match: zh-Hant-CN-x-private1-private2
1. zh-Hant-CN-x-private1-private2
2. zh-Hant-CN-x-private1
3. zh-Hant-CN
4. zh-Hant
5. zh
6. (default)
public static void main(String[] args) {
System.out.println(new Locale("zh-hant", "CN"));
}
in jdk1.5 -> 1.8
jdk1.5 zh-hant_CN
jdk1.6 zh-hant_CN
jdk1.7 zh-hant_CN
jdk1.8 zh-hant_CN
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Serializing and Deserializing Locale.ROOT #1123 - GitHub
Serializing and Deserializing Locale objects seems to work just fine, until you try on the Root Locale. It writes it out as an...
Read more >Deserialize Java 8 LocalDateTime with JacksonMapper
The date time you're passing is not an ISO local date time format. Change to @Column(name = "start_date") @DateTimeFormat(iso = DateTimeFormatter.
Read more >How to format java.util.Locale or any type of Object when ...
In our first example, StdConverter<Locale, String>, Locale is the IN object and String is the return type of this method; OUT. abstract OUT...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
At this point I am not sure what expected handling would be; and I do not think proposed solution is correct. It is NOT correct to say that underscore (
_
) is the canonical separator, for example: RFCs that specify this claim hyphen should be used. Yet JDK prefers underscore for legacy reasons. Some more discussion can be found from answers on:https://softwareengineering.stackexchange.com/questions/325458/parse-both-en-us-and-en-us-as-locale-in-java/367706#367706
Finally, I don’t think Jackson 2.9 should change handling unless it can be guaranteed change does not break existing usage. Because of this, I think I will change 3.0 to use
toLanguageTag()
andforLanguageTag()
, but leave 2.9 as is.Another possibility: JDK 1.7 has
Locale.forLanguageTag(String)
. I could possibly change code for next minor or major version to use that (although probably not safe for patch), if that is an improvement.