Locale.toString

Returns a string representation of this <code>Locale</code> object, consisting of language, country, variant, script, and extensions as below: <blockquote> language ~ "_" ~ country ~ "_" ~ (variant ~ "_#" | "#") + script ~ "_" ~ extensions </blockquote>

Language is always lower case, country is always upper case, script is always title case, and extensions are always lower case. Extensions and private use subtags will be in canonical order as explained in {@link #toLanguageTag}.

<p>When the locale has neither script nor extensions, the result is the same as in Java 6 and prior.

<p>If both the language and country fields are missing, this function will return the empty string, even if the variant, script, or extensions field is present (you can't have a locale with just a variant, the variant must accompany a well-formed language or country code).

<p>If script or extensions are present and variant is missing, no underscore is added before the "#".

<p>This behavior is designed to support debugging and to be compatible with previous uses of <code>toString</code> that expected language, country, and variant fields only. To represent a Locale as a string for interchange purposes, use {@link #toLanguageTag}.

<p>Examples: <ul> <li>{@code en}</li> <li>{@code de_DE}</li> <li>{@code _GB}</li> <li>{@code en_US_WIN}</li> <li>{@code de__POSIX}</li> <li>{@code zh_CN_#Hans}</li> <li>{@code zh_TW_#Hant_x-java}</li> <li>{@code th_TH_TH_#u-nu-thai}</li></ul>

@return A string representation of the Locale, for debugging. @see #getDisplayName @see #toLanguageTag

class Locale
override
string
toString
()

Meta