The Java Locale getDefault() method gets the current value of the default locale for this instance of the Java Virtual Machine.
DeclarationFollowing is the declaration for java.util.Locale.getDefault() method
public static Locale getDefault()Parameters
NA
Return ValueThis method returns the default locale for this instance of the Java Virtual Machine
ExceptionNA
Getting Default Locale ExampleThe following example shows the usage of Java Locale getDefault() method. We're creating a default locale using getDefault() method and printed it.
package com.tutorialspoint; import java.util.Locale; 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); } }Output
Let us compile and run the above program, this will produce the following result −
Locale:en_IN
java_util_locale.htm
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4