Java Locale getDisplayName() method7 Nov 2024 | 2 min read The getDisplayName() method of Locale class is used to return a name for the locale that is appropriate for display to the user. This will be the value returned by getDisplayScript(), getDisplayLanguage(), getDisplayCountry(), and getDisplayVariant() assembled into a single string. SyntaxParameterNA ReturnThis method does not return a value. Example 1Output: Locale: english_IN Name: english (India) Example 2Output: Locale1: english_IN Locale2: german_AU Name of Locale1: english (India) Name of Locale2: german (Australia) Example 3Output: Locale1: spanish_EC Locale2: french_BE Locale3: french_BE Name of Locale1: spanish (Ecuador) Name of Locale2: french (Belgium) Name of Locale3: german (Australia) Java Locale getDisplayName(Locale inLocale) methodThe getDisplayName(Locale inLocale) method of Locale class is used to return a name for the locale that is appropriate for display to the user. This will be the value returned by getDisplayScript(), getDisplayLanguage(), getDisplayCountry(), and getDisplayVariant() assembled into a single string. SyntaxThrowsNullPointerException: This exception will throw if inLocale is null. Example 4Output: Locale: english_IN Name of in Locale: english (India) Example 5Output: Locale1: english_IN Locale2: spanish_EC Name of in Locale1: english (India) Name of in Locale2: spanish (Ecuador) Next TopicJava-locale-getdisplayvariant-method |
The getDefault() method of Java Locale class is used to get the current value of the default locale for this instance of the JVM(Java Virtual Mchine). Syntax public static Locale getDefault() Return It returns the default locale for this instance of the Java Virtual Machine Example 1 import java.util.*; public class LocaleGetDefaultExample1...
1 min read
The getISO3Language() method of Java Locale class returns a three-letter abbreviation for this locale's language. If the locale doesn't specify a language, this method will return an empty string. Otherwise, this method will return an uppercase ISO 3166 3-letter language code. Syntax public String getISO3Language() Parameter NA Return value This method returns...
2 min read
The getLanguage() method of Java Locale class is used to return the language code of this Locale. Syntax public String getLanguage() Parameter NA Return This method returns the language code or the empty string if none is defined. Example 1 import java.util.*; public class LocaleGetLanguageExample1 { public static void main(String[] args) { ...
1 min read
The getCountry() method of Java Locale class returns the country/region code for this locale. This code can either be the empty string, an uppercase ISO 3166 2-letter code. If none is defined, this method will return the empty string. Syntax public String getCountry() Parameter NA Return The getCountry() method returns the...
2 min read
The equals() method of Java Locale class returns true if this Locale is equal to another object. A Locale is deemed equal to another Locale with identical language, variant, country, extension, script, and unequal to all other objects. Syntax public boolean equals(Object obj) Parameter obj: It is the reference...
3 min read
The hashCode() method of Java Locale class returns a hash code for this locale. This method overrides the hashCode. Syntax public int hashCode() Return It returns a hash code value for this locale. Example 1 import java.util.*; public class LocaleHashCodeExample1 { public static void main(String[] args) { // create a new locale ...
1 min read
The clone() method of Java Locale class is used to create a copy of this locale. This method returns the clone of this instance. Syntax public Object clone() Parameter NA Return This method returns a clone of this instance. Example 1 import java.util.*; public class LocaleCloneExample1 { public static void main(String[] args) { //...
2 min read
The toString() method of Locale class is used to return a string representation of this Locale object, consisting of language, country, variant, script, and extensions. Syntax public final String toString() Parameter NA Return This method returns a string representation of the Locale, for debugging. Example 1 import java.util.*; public class LocaleToStringExample1 { public...
2 min read
The setDefault() method of Java Locale class is used to set the default locale for this instance of the JVM(Java Virtual Machine). It does not affect the host locale. Syntax public static void setDefault(Locale newLocale) Parameter newLocale: It is the new default locale. Return NA Exceptions SecurityException: This exception will throw if a security...
2 min read
The getDisplayVaiant() method of Java Locale class is used to return a name for the locale's variant code that is appropriate for display to the user. This method returns the empty string if the locale doesn't specify a variant code. Syntax public final String getDisplayVariant() Parameter NA Example 1 import java.util.*; public class...
3 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India