how-to

Internationalization

How to get current Locale

For work with Locale class you need to use:

import java.util.Locale;

Locale object contains settings for internationlization. For get current active Locale information, use this code:

System.out.println( Locale.getDefault() );

System.out.println( Locale.getDefault().toString() );
    
System.out.println( Locale.getDefault().getDisplayCountry() );

System.out.println( Locale.getDefault().getISO3Country() );

System.out.println( Locale.getDefault().getDisplayName() );

The output is:

en_US
en_US
United States
USA
English (United States)

The first two letters in the shortcut is language, second is the country.