3

Why does java.util.Locale.US show en_US? When we construct, why do we need to pass it as en-US?

What is the difference between these?

Worthwelle
  • 1,165
  • 1
  • 16
  • 18
Sundar
  • 335
  • 2
  • 9
  • 1
    Does this answer your question? [What is the difference between creating locale for en-US and en\_US?](https://stackoverflow.com/questions/4632885/what-is-the-difference-between-creating-locale-for-en-us-and-en-us) – andrewJames Jun 23 '20 at 20:42
  • More answers here also: [en_US or en-US, which one should you use?](https://stackoverflow.com/questions/4904803/en-us-or-en-us-which-one-should-you-use). – andrewJames Jun 23 '20 at 20:45

1 Answers1

2

You see both versions quite often. However, RFC 5646 (which is part of the IETF BCP 47 document series) prescribes a hyphen as the separator character. Java seems to allow both versions:

Well-formed variant values have the form SUBTAG (('_'|'-') SUBTAG)* where SUBTAG = [0-9][0-9a-zA-Z]{3} | [0-9a-zA-Z]{5,8}. (Note: BCP 47 only uses hyphen ('-') as a delimiter, this is more lenient).

Community
  • 1
  • 1
martin_wun
  • 1,360
  • 1
  • 12
  • 28