Get Locale object

What is Locale?

Information that represents a "region" divided by country or language. Locale is represented by an object of class java.util.Locale.

Acquisition of Locale object Part 1

Myclass.java


Locale loc = new Locale("ja"); //ja
Locale loc = new Locale("en","US"); //en_US
Locale loc = new Locale("fr","CA","POSIX"); //fr_CA_POSIX

Acquisition of Locale object Part 2

Myclass.java


Local loc = new Locale.Builder().setLanguage("ja").setRegion("JP").build();
//ja_JP

Summary

Keep in mind that there are the above two patterns for getting locale objects.

Recommended Posts

Get Locale object
Get "2-4, 7, 9" from [4, 7, 9, 2, 3]