Locale stripExtensions() in Java

stripExtensions(): This method is available in java.util.Locale class of Java.

Syntax:

Locale java.util.Locale.stripExtensions()

This method returns a copy of this Locale with no extensions. If this Locale has no extensions, this Localeis returned.

Returns: a copy of this Locale with no extensions, or this if this has no extensions.

For Example:

Locale locale = new Locale("en", "USA", "US")

locale.stripExtensions() = > It returns en_USA_US.

Approach

Java

import java.util.Locale;

public class LocalestripExtensions {
    public static void main(String[] args) {

        Locale locale = new Locale("en""USA""US");

        System.out.println(locale.stripExtensions());
    }
}

Output:

en_USA_US

No comments:

Post a Comment