Javatpoint Logo
Javatpoint Logo

Java Locale setDefault() method

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

Parameter

newLocale: It is the new default locale.

Return

NA

Exceptions

SecurityException: This exception will throw if a security manager exists and its checkPermission method doesn't allow the operation.

NullPointerException: This exception will throw if newLocale is null.

Example 1

Test it Now

Output:

Locale1: en_US_WIN

Example 2

Test it Now

Output:

Locale1: en_US
NEW Default locale2: fr_FRANCE_MAC
Locale3: fr_FRANCE_MAC
NEW Default locale4: en_US_WIN
Next TopicJava Locale



Help Others, Please Share

facebook twitter pinterest