Locale getISO3Language() Method in Java with Examples
Last Updated :
27 Dec, 2018
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:
import java.util.*;
public class Locale_Demo {
public static void main(String[] args)
{
Locale first_locale
= new Locale( "en" , "IN" );
System.out.println( "First Locale: "
+ first_locale);
System.out.println( "Language: "
+ first_locale.getISO3Language());
}
}
|
Output:
First Locale: en_IN
Language: eng
Program 2:
import java.util.*;
public class Locale_Demo {
public static void main(String[] args)
{
Locale first_locale
= new Locale( "ar" , "SA" );
System.out.println( "First Locale: "
+ first_locale);
System.out.println( "Language: "
+ first_locale.getISO3Language());
}
}
|
Output:
First Locale: ar_SA
Language: ara
Program 3: Showing Error
import java.util.*;
public class Locale_Demo {
public static void main(String[] args)
{
Locale first_locale
= new Locale( "engh" , "US" );
System.out.println( "First Locale: "
+ first_locale);
try {
System.out.println( "Language: "
+ first_locale.getISO3Language());
}
catch (Exception e) {
System.out.println(e);
}
}
}
|
Output:
First Locale: engh_US
java.util.MissingResourceException: Couldn't find 3-letter language code for engh
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...