Hi Jon,
JDK historically represents Norwegian Nynorsk language with no_NO_NY
(JDK unique "NY" variant), because it predates the ISO 639-1:2002
standard which introduced "nn" as the language code for Nynorsk. This
legacy JDK locale is converted to BCP47 compliant language tag using
"nn" language code.
Locale.toLanguageTag() has the following sentence for this:
---
A locale with language "no", country "NO", and variant "NY",
representing Norwegian Nynorsk (Norway), is converted to a language tag
"nn-NO".
---
So in short, that is the expected behavior.
Naoto
On 6/7/18 2:19 PM, Jonathan Gibbons wrote:
Regarding Locale.toLanguageTag, Locale.forLanguageTag
Should I be surprised (i.e. is it a bug) that out of 736 installed
locales in a standard build of JDK, exactly 1 locale fails the following
round-trip test:
locale.equals(Locale.forLanguageTag(locale.toLanguageTag()))
The locale "no_NO_NY" comes back as "nn_NO".
Attached is a test program. Here is the output from the test program:
$ /opt/jdk/1.9.0/bin/java -cp play/locales/classes Locales
test locale: no_NO_NY [no,NO,NY] nn-NO
forLanguageTag: nn_NO
Tested 736 locales
Mismatch 1 locales
-- Jon