Locale location Java Android example

Locale lc = Locale.getDefault(); // default now locale on device
	String sCountry = lc.getCountry(); // CZ
 
	lc = new Locale("fr","FR"); //FRANCE .. Locale(language, country);
	String sCountry2 = lc.getDisplayCountry(); // Francie
 
	 Locale locale = Locale.GERMAN;					    
	 String sCountry3 = locale.getDisplayCountry(); // ""
 
 Locale locale = Locale.GERMAN;
 DateFormat formatter = new SimpleDateFormat("HH:mm:ss zzzz", locale);
 String s = formatter.format(new Date());//13:40:39 GMT+00:00					
 
 
// array of locales   
 Locale[] locales = { new Locale("fr", "FR"), new Locale("de", "DE"),
				        new Locale("en", "US") };
 
 
Locale locale = Locale.US;
 
// for date
DateFormat dateFormatterEurope = DateFormat.getDateInstance(DateFormat.DEFAULT,
					Locale.GERMANY);
Calendar myCalendar = Calendar.getInstance();
String sDate = dateFormatterEurope.format(myCalendar.getTime());
 
        final byte[] langBytes = locale.getLanguage().getBytes(Charsets.US_ASCII);
 
// UTF-8 most widely used text format for to properly display of text
        final Charset utfEncoding = Charsets.UTF_8;
        String text = "ěščřžýáíéůú"; 
        final byte[] textBytes = text.getBytes(utfEncoding);
 
 
// other Locale
CANADA
CANADA_FRENCH
CHINA
CHINESE
ENGLISH
FRANCE
FRENCH
GERMAN
GERMANY
ITALIAN
ITALY
JAPAN
JAPANESE
KOREA
KOREAN
PRC // Locale constant for zh_CN. 
ROOT // Locale constant for the root locale. 
SIMPLIFIED_CHINESE
TAIWAN
TRADITIONAL_CHINESE Locale constant for zh_TW. 
UK
US
This entry was posted in Android Examples Code and tagged , , . Bookmark the permalink.


Comments are closed.



9,930 views