Locale getCountry() Method in Java with Examples Last Updated : 27 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The getCountry() method of Locale class in Java is used to get the country or region code for the specified locale. This will either be an empty string or an uppercase ISO 3166 2-letter code, or a UN M.49 3-digit code. Syntax: LOCALE.getCountry() Parameters: This method does not take any parameters. Return Value: This method returns the country code of a given locale or an empty string if the locale is empty. Below programs illustrate the working of getCountry() method: Program 1: Java // Java code to illustrate getCountry() method import java.util.*; public class Locale_Demo { public static void main(String[] args) { // Creating a new locale Locale first_locale = new Locale("English", "UK"); // Displaying first locale System.out.println("First Locale: " + first_locale); // Displaying the country_code of this locale System.out.println("Country: " + first_locale.getCountry()); } } Output: First Locale: english_UK Country: UK Program 2: Java // Java code to illustrate getCountry() method import java.util.*; public class Locale_Demo { public static void main(String[] args) { // Creating a new locale Locale first_locale = new Locale("English", "India"); // Displaying first locale System.out.println("First Locale: " + first_locale); // Displaying the country_code of this locale System.out.println("Country: " + first_locale.getCountry()); } } Output: First Locale: english_INDIA Country: INDIA Comment More infoAdvertise with us Next Article Locale getCountry() Method in Java with Examples chinmoy lenka Follow Improve Article Tags : Java Java - util package Java-Functions Java-Locale Practice Tags : Java Similar Reads Locale getISO3Country() Method in Java with Examples The getISO3Country() method of Locale class in Java is used to get the country or region code for the specified locale. This will either be an uppercase ISO 3166 3-letter country code or an empty string if the locale doesn't specify a country. Syntax: LOCALE.getISO3Country() Parameters: This method 2 min read Locale getDisplayCountry() Method in Java with Examples The getDisplayCountry() method of Locale class in Java is used to get the country or region name for the specified locale. This name is displayed according to the convenience of the user. Syntax: LOCALE.getDisplayCountry() Parameters: This method does not take any parameters. Return Value: This meth 1 min read Locale getISOCountries() Method in Java with Examples The getISOCountries() Method of Locale class in Java is used get the collection of arrays of all available two-letter country codes officially defined in ISO 3166. Syntax: Locale.getISOCountries() Parameters: This method does not take any parameters. Return Value: This method returns the array colle 2 min read LocalTime getHour() method in Java with Examples The getHour() method of a LocalTime class is used to return the hour-of-day field. This method returns an integer value ranging from 0 to 23, i.e. the Hours of a day. Syntax: public int getHour() Parameters: This method does not accept any parameter. Return value: This method returns an integer valu 1 min read Locale getVariant() Method in Java with Examples The getVariant() method of Locale class in Java is used to get a variant code for the specified locale. It returns an empty string if nothing is specified Syntax: LOCALE.getLanguage() Parameters: This method does not take any parameters. Return Value: This method either returns an empty string or th 1 min read LocalTime getSecond() method in Java with Examples The getSecond() method of a LocalTime class is used to return the second-of-minute field. This method returns an integer value ranging from 0 to 59, i.e. the Seconds of a minute. Syntax: public int getSecond() Parameters: This method does not accept any parameter. Return value: This method returns a 1 min read LocalDateTime getHour() method in Java with Examples The getHour() method of an LocalDateTime class is used to return the hour-of-day field. This method returns an integer value ranging from 0 to 23, i.e. the Hours of a day. Syntax: public int getHour() Parameter: This method does not accept any parameter. Returns: This method returns an integer value 1 min read LocalDate getEra() method in Java with Examples The getEra() method of LocalDate class in Java gets the era applicable at this date. Syntax: public Era getEra() Parameter: This method does not accepts any parameter. Return Value: The function returns the IsoChronology era constant applicable at this date and not null. Below programs illustrate th 1 min read Locale getDisplayCountry(Locale) Method in Java with Examples The getDisplayCountry(Locale inLoc) method of Locale class in Java is used to get the country or region name for the specified locale. This name would be localized according to inLoc. Syntax: public String getDisplayCountry(Locale inLoc) Parameters: This method takes one parameter inLoc of Locale ty 2 min read Locale getLanguage() Method in Java with Examples The getLanguage() method of Locale class in Java is used to get language code for the specified locale. This will either be an empty string or a lowercase ISO 639 code. Syntax: LOCALE.getLanguage() Parameters: This method does not take any parameters. Return Value: This method either returns an empt 1 min read Like