Locale.Builder setLanguageTag() method in Java with Examples
The setLanguageTag(String) method of java.util.Locale.Builder class in Java is used to reset this Locale.Builder to the specified IETF BCP 47 language tag. It means that this method will reset the current state of Locale.Builder instance to match the provided language tag and return it.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
public Locale.Builder setLanguageTag(String languageTag)
Parameter: This method accepts the languageTag as the parameter which is the String that is to be set to this Locale.Builder instance.
Return Value: This method returns an Locale.Builder instance which is the state of this Locale.Builder set to the specified language tag.
Exception: This method throws following Exceptions:
- IllformedLocaleException: if the specified languageTag has any ill formed fields
LocaleBuilder: java.util.Locale$Builder@232204a1 Setting the language: FRENCH Updated LocaleBuilder: java.util.Locale$Builder@232204a1
LocaleBuilder: java.util.Locale$Builder@232204a1 Setting the languageTag: asdasf@!vsd# java.util.IllformedLocaleException: Invalid subtag: asdasf@!vsd# [at index 0]