Locale getISO3Language() Method in Java with Examples
The getISO3Language() method of Locale class in Java is used to get a three letter abbreviation for the language specified in the locale. This will either be a lowercase ISO 639-2/T language code or an empty string if the locale doesn’t specify a language.
Syntax:
LOCALE.getISO3Language()
Parameters: This method does not take any parameters.
Return Value: This method does not return any value.
Exception: The method throws a MissingResourceException if the three-letter language abbreviation is not available for the specified locale.
Below programs illustrate the working of getISO3Language() method:
Program 1:
// Java code to illustrate getISO3Language() method import java.util.*; public class Locale_Demo { public static void main(String[] args) { // Creating a new locale Locale first_locale = new Locale("en", "IN"); // Displaying first locale System.out.println("First Locale: " + first_locale); // Displaying the language_code of this locale System.out.println("Language: " + first_locale.getISO3Language()); } } |
First Locale: en_IN Language: eng
Program 2:
// Java code to illustrate getISO3Language() method import java.util.*; public class Locale_Demo { public static void main(String[] args) { // Creating a new locale Locale first_locale = new Locale("ar", "SA"); // Displaying first locale System.out.println("First Locale: " + first_locale); // Displaying the language_code of this locale System.out.println("Language: " + first_locale.getISO3Language()); } } |
First Locale: ar_SA Language: ara
Program 3: Showing Error
// Java code to illustrate getISO3Language() method import java.util.*; public class Locale_Demo { public static void main(String[] args) { // Creating a new locale Locale first_locale = new Locale("engh", "US"); // Displaying first locale System.out.println("First Locale: " + first_locale); try { // Displaying the language_code of this locale System.out.println("Language: " + first_locale.getISO3Language()); } catch (Exception e) { System.out.println(e); } } } |
First Locale: engh_US java.util.MissingResourceException: Couldn't find 3-letter language code for engh
Recommended Posts:
- Locale setDefault(Locale.Category, Locale) Method in Java with Examples
- Locale.Builder setLocale(Locale) method in Java with Examples
- TimeZone getDisplayName(Locale locale) Method in Java with Examples
- Locale getDisplayVariant(Locale inLoc) Method in Java with Examples
- Locale getDisplayLanguage(Locale) Method in Java with Examples
- Locale getDisplayName(Locale) Method in Java with Examples
- Locale getDisplayCountry(Locale) Method in Java with Examples
- Locale getISOLanguages() Method in Java with Examples
- Locale toString() Method in Java with Examples
- Locale toLanguageTag() Method in Java with Examples
- Locale getCountry() Method in Java with Examples
- Locale getAvailableLocales() Method in Java with Examples
- Locale getVariant() Method in Java with Examples
- Locale getExtensionKeys() Method in Java with Examples
- Locale getLanguage() Method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



