public String toLanguageTag ()

Returns a well-formed IETF BCP 47 language tag representing this locale.

If this Locale has a language, country, or variant that does not satisfy the IETF BCP 47 language tag syntax requirements, this method handles these fields as described below:

Language: If language is empty, or not well-formed (for example "a" or "e2"), it will be emitted as "und" (Undetermined).

Country: If country is not well-formed (for example "12" or "USA"), it will be omitted.

Variant: If variant is well-formed, each sub-segment (delimited by '-' or '_') is emitted as a subtag. Otherwise:

Special Conversions: Java supports some old locale representations, including deprecated ISO language codes, for compatibility. This method performs the following conversions:

Note: Although the language tag created by this method is well-formed (satisfies the syntax requirements defined by the IETF BCP 47 specification), it is not necessarily a valid BCP 47 language tag. For example,

   new Locale("xx", "YY").toLanguageTag();
will return "xx-YY", but the language subtag "xx" and the region subtag "YY" are invalid because they are not registered in the IANA Language Subtag Registry.

Returns:  a BCP47 language tag representing the locale

See also:
forLanguageTag(String)

Since:  1.7