getISO3Language(): This method is available in java.util.Locale class of Java.
Syntax:
String java.util.Locale.getISO3Language() throws MissingResourceException
This method returns a three-letter abbreviation of this locale's language. If the language matches an ISO 639-1 two-letter code, the corresponding ISO 639-2/T three-letter lowercase code is returned.
Returns: A three-letter abbreviation of this locale's language.
Throws: MissingResourceException - if three-letter language abbreviation is not available for this locale.
For Example:
Locale locale = new Locale("en", "IN")
locale.getISO3Language() = > It returns eng.
Approach 1: When 3-letter language code is found.
Java
import java.util.Locale;public class LocalegetISO3Language {public static void main(String[] args) {Locale locale = new Locale("en", "IN");System.out.println(locale.getISO3Language());}}
Output:
eng
Approach 2: When 3-letter language code not found.
Java
import java.util.Locale;public class LocalegetISO3Language {public static void main(String[] args) {Locale locale = new Locale("engg", "IN");System.out.println(locale.getISO3Language());}}
Output:
Exception in thread "main" java.util.MissingResourceException:Couldn't find 3-letter language code for engg at java.base/java.util.Locale.getISO3Language(Locale.java:1752)
No comments:
Post a Comment