Java.util.Locale.getCountry() Method


Advertisements


Description

The java.util.Locale.getDefault() method gets the current value of the default locale for this instance of the Java Virtual Machine.

Declaration

Following is the declaration for java.util.Locale.getDefault() method

public static Locale getDefault()

Parameters

  • NA

Return Value

This method returns the default locale for this instance of the Java Virtual Machine

Exception

  • NA

Example

The following example shows the usage of java.util.Locale.getDefault() method.

package com.tutorialspoint;

import java.util.*;

public class LocaleDemo {

   public static void main(String[] args) {

   // create a new locale
   Locale locale = Locale.getDefault();

   // print the default locale
   System.out.println("Locale:" + locale);

   }
}

Let us compile and run the above program, this will produce the following result:

Locale:el_GR

java_util_locale.htm

Advertisements