Locale toLanguageTag() Method in Java with Examples
The toLanguageTag() method of Locale class in Java is used to return a well-formed IETF BCP 47 language tag representing this locale object. Now there can be few complications when a language, country or variant does not satisfy the above-mentioned tag which is handled well by this method:
- If the mentioned language does not satisfy the tag, then it will be emitted as Undetermined or “und”.
- If the mentioned country does not satisfy the tag, it will be omitted.
- If the same occurs with the Variant, then each sub-segment is emitted as a subtag.
public String toLanguageTag()
Parameters: This method does not take any parameters.
Return Value: This method returns IETF BCP 47 language tag representation of this locale.
Below programs illustrate the working of toLanguageTag() method:
Locale: germany The LanguageTag: germany
Locale: en_USA The LanguageTag: en
My Personal Notes arrow_drop_up
Please Login to comment...