Locale.toString() has the following syntax.
public final String toString()
In the following code shows how to use Locale.toString() method.
//w w w .ja v a2s. c o m import java.util.Locale; public class Main { public static void main(String[] args) { Locale locale1 = new Locale("en", "US", "WIN"); System.out.println("Locale:" + locale1); // print the locale as a string System.out.println("Locale:" + locale1.toString()); Locale locale2 = new Locale("fr", "FRANCE", "WIN"); System.out.println("Locale2:" + locale2); // print the locale as a string System.out.println("Locale2:" + locale2.toString()); } }
The code above generates the following result.