Best code examples for Java 8 Locale class (java.util.Locale)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Locale class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 Locale examples from Open Source projects
This code example shows how to use the following methods: getCountry, getDisplayCountry, getDisplayLanguage, getDisplayName, getISO3Country
421:	System.out.println(loc.getDisplayName()); 
422:	System.out.println(loc.getCountry()); 
423:	System.out.println(loc.getLanguage()); 
424:	System.out.println(loc.getDisplayCountry()); 
425:	System.out.println(loc.getDisplayLanguage()); 
426:	System.out.println(loc.getDisplayName()); 
427:	System.out.println(loc.getISO3Country()); 
428:	System.out.println(loc.getISO3Language()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage
116:	database.getStorage().getConfiguration().setLocaleLanguage(Locale.ENGLISH.getLanguage()); 
117:	database.getStorage().getConfiguration().setLocaleCountry(Locale.ENGLISH.getCountry()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDefault
32:	Locale locale = new Locale(code); 
33:	Locale.setDefault(locale); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage, getVariant
256:	String language = locale.getLanguage(); 
257:	String country = locale.getCountry(); 
258:	String variant = locale.getVariant(); 
-
262:	locales.add(locale); 
-
265:	locales.add((locales.size() == 0) ? locale : new Locale(language, country)); 
-
268:	locales.add((locales.size() == 0) ? locale : new Locale(language)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getDisplayCountry, getDisplayLanguage, getDisplayName, getDisplayVariant
33:	Locale invalid = new Locale("AaBbCc", "DdEeFf", "GgHhIi"); 
-
35:	assertEquals("aabbcc", invalid.getLanguage()); 
36:	assertEquals("DDEEFF", invalid.getCountry()); 
37:	assertEquals("GgHhIi", invalid.getVariant()); 
-
42:	assertEquals("aabbcc", invalid.getDisplayLanguage()); 
43:	assertEquals("", invalid.getDisplayCountry()); 
44:	assertEquals("DDEEFF_GGHHII", invalid.getDisplayVariant()); 
45:	assertEquals("aabbcc (DDEEFF,DDEEFF_GGHHII)", invalid.getDisplayName()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage, getVariant
96:	String lang = locale.getLanguage(); 
97:	String country = locale.getCountry(); 
98:	String variant = locale.getVariant(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods:
244:	Locale l = new Locale(language, country, variant); 
245:	locales.put(code, l); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage, getVariant
54:	String language = locale.getLanguage(); 
55:	String country = locale.getCountry(); 
56:	String variant = locale.getVariant(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods:
104:	locale = new Locale(entry.language, entry.iso); 
-
106:	String[] tz = TimeZones.forLocale(locale); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods:
20:	return new Locale(value.substring(0, 2), value.substring(3, 5)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods:
83:	Locale inLocale = new Locale("en", "IN"); 
84:	if (Support_Locale.isLocaleAvailable(inLocale)) { 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDefault
129:	Locale.setDefault(expectGermanFallback ? Locale.GERMAN : Locale.CANADA); 
-
134:	assertEquals("nachricht2", ac.getMessage("code2", null, Locale.GERMAN)); 
-
193:	assertEquals("code4", ac.getMessage("code4", null, Locale.GERMAN)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDefault
135:	setLocale(new Locale("sv", "SE"), false); 
-
155:	Locale.setDefault(locale2); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods:
36:	protected static final PrettyTime pt = new PrettyTime(new Locale("")); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDefault
64:	Locale.setDefault(locale); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods:
130:	Locale locale = new Locale("en", "GB"); 
131:	row.generateTableRows(stringBuilder, list, locale, locale, 0); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods:
174:	return new Locale(parts[0], parts[1]); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage, getVariant
106:	String language = locale.getLanguage(); 
107:	String country = locale.getCountry(); 
108:	String variant = locale.getVariant(); 
-
113:	locales.add(locale); 
-
116:	locales.add((locales.size() == 0) ? locale : new Locale(language, country, "")); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getDisplayCountry, getDisplayLanguage, getVariant
199:	Locale loc = new Locale(mVoiceLanguage, mVoiceCountry, mVoiceVariant); 
200:	String displayName = loc.getDisplayLanguage() + 
201:	"(" + loc.getDisplayCountry() + "," + loc.getVariant() + ")"; 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods:
66:	languages(new Locale("en")).languages(new Locale("fr")).add(). 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getLanguage, toString
168:	String encoding = (String)_localeEncodingMap.get(locale.toString()); 
-
170:	encoding = (String)_localeEncodingMap.get(locale.getLanguage()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage
71:	if (header.getCountry().length() == 0) { 
72:	return header.getLanguage(); 
-
74:	StringBuilder sb = new StringBuilder(header.getLanguage()); 
75:	return sb.append('-').append(header.getCountry()).toString(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: toString
74:	Assert.notNull(locale, "Locale must not be null"); 
-
76:	this.messages.put(code + "_" + locale.toString(), msg); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getDisplayCountry
120:	? "" : new Locale("", regionCode).getDisplayCountry(language); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage
76:	String language = locale.getLanguage(); 
-
78:	String country = locale.getCountry(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage, getVariant
90:	localeJSONObject.put("country", locale.getCountry()); 
91:	localeJSONObject.put("language", locale.getLanguage()); 
92:	localeJSONObject.put("variant", locale.getVariant()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage, toString
105:	String charset = map.getProperty(locale.toString()); 
-
107:	charset = map.getProperty(locale.getLanguage() + "_" 
108:	+ locale.getCountry()); 
-
110:	charset = map.getProperty(locale.getLanguage()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getLanguage
157:	if (Locale.SIMPLIFIED_CHINESE.getLanguage().equals(language)) { 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDefault
64:	Locale.setDefault(locale); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getLanguage
144:	Preconditions.checkNotNull(locale); 
-
146:	byte[] langBytes = locale.getLanguage().getBytes(Charset.forName("US-ASCII")); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry
50:	if ("ISBN".equals(type) && !Locale.US.getCountry().equals(country)) { 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods:
82:	Locale locale = new Locale("EN"); 
83:	Assert.assertEquals(DateUtils.getCurrentDate(locale), LoanUIHelperFn.getCurrrentDate(locale)); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage, getVariant
65:	_defaultLocale.getLanguage(), _defaultLocale.getCountry(), 
66:	_defaultLocale.getVariant()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: equals, setDefault
139:	appLocale = LengthUtils.isNotEmpty(lang) ? new Locale(lang) : defLocale; 
-
144:	if (!config.locale.equals(appLocale)) { 
145:	Locale.setDefault(appLocale); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage, getVariant
53:	if ("".equals(l.getCountry())) 
-
55:	return l.getLanguage(); 
-
57:	else if ("".equals(l.getVariant())) 
-
59:	return l.getLanguage() + '_' + l.getCountry(); 
-
63:	return l.getLanguage() + '_' + l.getCountry() + '_' + l.getVariant(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: setDefault
32:	Locale locale = new Locale(code); 
33:	Locale.setDefault(locale); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods:
82:	languages(new Locale("en")).add(). 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage
107:	return primaryTag.equalsIgnoreCase(tag.getLanguage()); 
-
109:	return primaryTag.equalsIgnoreCase(tag.getLanguage()) 
110:	&& subTags.equalsIgnoreCase(tag.getCountry()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage, getVariant
100:	String lang = locale.getLanguage(); 
101:	String country = locale.getCountry(); 
102:	String variant = locale.getVariant(); 
103:	String suffix = "_" + locale.getLanguage(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: setDefault
183:	Locale.setDefault(new Locale("nl", "nl")); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage, getVariant
75:	_defaultLocale.getLanguage(), _defaultLocale.getCountry(), 
76:	_defaultLocale.getVariant()); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage
363:	String language = convertObsoleteLanguageCodeToNew(locale.getLanguage()); 
-
366:	String country = locale.getCountry(); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage, getVariant
73:	_defaultLocale.getLanguage(), _defaultLocale.getCountry(), 
74:	_defaultLocale.getVariant()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: getCountry, getLanguage
154:	userPreferredLocale = locale.getLanguage() + "_" + locale.getCountry(); 
Full Snippet Info
7
CodeRank
Related Java 8 Locale Questions & Answers:
See Code Examples for Java 8 Locale Methods: