Formatter locale() in Java

locale(): This method is available in java.util.Formatter class of Java.

Syntax:

Locale java.util.Formatter.locale()

This method returns the locale set by the construction of this formatted.

Parameters: NA

Returns: null if no localization is applied, otherwise alocale.

Throws:

FormatterClosedException - If this formatter has been closed by invoking its close() method

Approach

Java

import java.util.Formatter;
import java.util.Locale;

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

        StringBuffer buffer = new StringBuffer();

        @SuppressWarnings("resource")
        Formatter formatter = new Formatter(buffer, Locale.UK);

        System.out.println(formatter.locale());

    }
}

Output:

en_GB


No comments:

Post a Comment