本文整理了Java中java.util.Locale.getDisplayName()
方法的一些代码示例,展示了Locale.getDisplayName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Locale.getDisplayName()
方法的具体详情如下:
包路径:java.util.Locale
类名称:Locale
方法名:getDisplayName
[英]Equivalent to getDisplayName(Locale.getDefault()).
[中]等效于getDisplayName(Locale.getDefault())。
代码示例来源:origin: Clans/FloatingActionButton
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.mTextView.setText(mLocales[position].getDisplayName());
}
代码示例来源:origin: robovm/robovm
/**
* Equivalent to {@code getDisplayName(Locale.getDefault())}.
*/
public final String getDisplayName() {
return getDisplayName(getDefault());
}
代码示例来源:origin: stackoverflow.com
String locale = context.getResources().getConfiguration().locale.getDisplayName();
String locale = java.util.Locale.getDefault().getDisplayName();
代码示例来源:origin: spring-projects/spring-framework
/**
* A variant of {@link #getAcceptLanguage()} that converts each
* {@link java.util.Locale.LanguageRange} to a {@link Locale}.
* @return the locales or an empty list
* @throws IllegalArgumentException if the value cannot be converted to a locale
* @since 5.0
*/
public List<Locale> getAcceptLanguageAsLocales() {
List<Locale.LanguageRange> ranges = getAcceptLanguage();
if (ranges.isEmpty()) {
return Collections.emptyList();
}
return ranges.stream()
.map(range -> Locale.forLanguageTag(range.getRange()))
.filter(locale -> StringUtils.hasText(locale.getDisplayName()))
.collect(Collectors.toList());
}
代码示例来源:origin: stanfordnlp/CoreNLP
private static String getLanguageStr(Properties props) {
return getLanguage(props).getDisplayName().toLowerCase();
}
代码示例来源:origin: Graylog2/graylog2-server
public static LocaleDescription create(Locale locale) {
return create(locale.toLanguageTag(), locale.getDisplayName(Locale.ENGLISH));
}
代码示例来源:origin: stackoverflow.com
final Locale[] availableLocales=Locale.getAvailableLocales();
for(final Locale locale : availableLocales)
Log.d("Applog",":"+locale.getDisplayName()+":"+locale.getLanguage()+":"
+locale.getCountry()+":values-"+locale.toString().replace("_","-r"));
代码示例来源:origin: org.springframework/spring-web
/**
* A variant of {@link #getAcceptLanguage()} that converts each
* {@link java.util.Locale.LanguageRange} to a {@link Locale}.
* @return the locales or an empty list
* @throws IllegalArgumentException if the value cannot be converted to a locale
* @since 5.0
*/
public List<Locale> getAcceptLanguageAsLocales() {
List<Locale.LanguageRange> ranges = getAcceptLanguage();
if (ranges.isEmpty()) {
return Collections.emptyList();
}
return ranges.stream()
.map(range -> Locale.forLanguageTag(range.getRange()))
.filter(locale -> StringUtils.hasText(locale.getDisplayName()))
.collect(Collectors.toList());
}
代码示例来源:origin: stackoverflow.com
public static boolean isRTL() {
return isRTL(Locale.getDefault());
}
public static boolean isRTL(Locale locale) {
final int directionality = Character.getDirectionality(locale.getDisplayName().charAt(0));
return directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT ||
directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
}
代码示例来源:origin: jphp-group/jphp
@Signature(@Arg(value = "locale", nativeType = WrapLocale.class, optional = @Optional("null")))
public Memory getDisplayName(Environment env, Memory... args) {
return StringMemory.valueOf(args[0].isNull()
? locale.getDisplayName()
: locale.getDisplayName(args[0].toObject(WrapLocale.class).locale)
);
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testTzParses() throws Exception {
// Check that all Locales can parse the time formats we use
for(final Locale locale : Locale.getAvailableLocales()) {
final FastDateParser fdp= new FastDateParser("yyyy/MM/dd z", TimeZone.getDefault(), locale);
for(final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) {
final Calendar cal= Calendar.getInstance(tz, locale);
cal.clear();
cal.set(Calendar.YEAR, 2000);
cal.set(Calendar.MONTH, 1);
cal.set(Calendar.DAY_OF_MONTH, 10);
final Date expected= cal.getTime();
final Date actual = fdp.parse("2000/02/10 "+tz.getDisplayName(locale));
assertEquals("tz:"+tz.getID()+" locale:"+locale.getDisplayName(), expected, actual);
}
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testTzParses() throws Exception {
// Check that all Locales can parse the time formats we use
for(final Locale locale : Locale.getAvailableLocales()) {
final FastDateParser fdp= new FastDateParser("yyyy/MM/dd z", TimeZone.getDefault(), locale);
for(final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) {
final Calendar cal= Calendar.getInstance(tz, locale);
cal.clear();
cal.set(Calendar.YEAR, 2000);
cal.set(Calendar.MONTH, 1);
cal.set(Calendar.DAY_OF_MONTH, 10);
final Date expected= cal.getTime();
final Date actual = fdp.parse("2000/02/10 "+tz.getDisplayName(locale));
Assert.assertEquals("tz:"+tz.getID()+" locale:"+locale.getDisplayName(), expected, actual);
}
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testTimeZoneStrategyPattern() {
for(final Locale locale : Locale.getAvailableLocales()) {
final FastDateParser parser = new FastDateParser("z", TimeZone.getDefault(), locale);
final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings();
for(final String[] zone : zones) {
for(int t = 1; t<zone.length; ++t) {
final String tzDisplay = zone[t];
if (tzDisplay == null) {
break;
}
try {
parser.parse(tzDisplay);
} catch(final Exception ex) {
fail("'" + tzDisplay + "'"
+ " Locale: '" + locale.getDisplayName() + "'"
+ " TimeZone: " + zone[0]
+ " offset: " + t
+ " defaultLocale: " + Locale.getDefault()
+ " defaultTimeZone: " + TimeZone.getDefault().getDisplayName()
);
}
}
}
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void structuredData() {
ThreadContext.put("loginId", "JohnDoe");
ThreadContext.put("ipAddress", "192.168.0.120");
ThreadContext.put("locale", Locale.US.getDisplayName());
final StructuredDataMessage msg = new StructuredDataMessage("Audit@18060", "Transfer Complete", "Transfer");
msg.put("ToAccount", "123456");
msg.put("FromAccount", "123457");
msg.put("Amount", "200.00");
logger.info(MarkerManager.getMarker("EVENT"), msg);
ThreadContext.clearMap();
final List<LogEvent> events = app.getEvents();
assertEquals("Incorrect number of events. Expected 1, actual " + events.size(), 1, events.size());
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl
@Test
public void testEventLogger() {
MDC.put("loginId", "JohnDoe");
MDC.put("ipAddress", "192.168.0.120");
MDC.put("locale", Locale.US.getDisplayName());
final EventData data = new EventData();
data.setEventType("Transfer");
data.setEventId("Audit@18060");
data.setMessage("Transfer Complete");
data.put("ToAccount", "123456");
data.put("FromAccount", "123457");
data.put("Amount", "200.00");
EventLogger.logEvent(data);
MDC.clear();
verify("EventLogger", "o.a.l.s.LoggerTest Transfer [Audit@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete" + Strings.LINE_SEPARATOR);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
protected void sendInfoStructuredMessage() {
ThreadContext.put("loginId", "JohnDoe");
ThreadContext.put("ipAddress", "192.168.0.120");
ThreadContext.put("locale", Locale.US.getDisplayName());
final StructuredDataMessage msg = new StructuredDataMessage("Transfer@18060", "Transfer Complete", "Audit");
msg.put("ToAccount", "123456");
msg.put("FromAccount", "123457");
msg.put("Amount", "200.00");
// the msg.toString() doesn't contain the parameters of the ThreadContext, so we must use the line1 string
final String str = msg.asString(null, null);
sentMessages.add(str);
root.info(MarkerManager.getMarker("EVENT"), msg);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-api
@Test
public void structuredData() {
ThreadContext.put("loginId", "JohnDoe");
ThreadContext.put("ipAddress", "192.168.0.120");
ThreadContext.put("locale", Locale.US.getDisplayName());
final StructuredDataMessage msg = new StructuredDataMessage("Transfer@18060", "Transfer Complete", "Audit");
msg.put("ToAccount", "123456");
msg.put("FromAccount", "123457");
msg.put("Amount", "200.00");
EventLogger.logEvent(msg);
ThreadContext.clearMap();
assertEquals(1, results.size());
final String expected = "EVENT OFF Audit [Transfer@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete";
assertThat("Incorrect structured data", results.get(0), startsWith(expected));
}
代码示例来源:origin: org.apache.logging.log4j/log4j-api
@Test
public void structuredData() {
ThreadContext.put("loginId", "JohnDoe");
ThreadContext.put("ipAddress", "192.168.0.120");
ThreadContext.put("locale", Locale.US.getDisplayName());
final StructuredDataMessage msg = new StructuredDataMessage("Audit@18060", "Transfer Complete", "Transfer");
msg.put("ToAccount", "123456");
msg.put("FromAccount", "123457");
msg.put("Amount", "200.00");
logger.info(MarkerManager.getMarker("EVENT"), msg);
ThreadContext.clearMap();
assertEquals(1, results.size());
assertThat("Incorrect structured data: ", results.get(0), startsWith(
"EVENT INFO Transfer [Audit@18060 Amount=\"200.00\" FromAccount=\"123457\" ToAccount=\"123456\"] Transfer Complete"));
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void structuredData() {
ThreadContext.put("loginId", "JohnDoe");
ThreadContext.put("ipAddress", "192.168.0.120");
ThreadContext.put("locale", Locale.US.getDisplayName());
final StructuredDataMessage msg = new StructuredDataMessage("Audit@18060", "Transfer Complete", "Transfer");
msg.put("ToAccount", "123456");
msg.put("FromAccount", "123457");
msg.put("Amount", "200.00");
logger.info(MarkerManager.getMarker("EVENT"), msg);
ThreadContext.clearMap();
final List<LogEvent> events = app.getEvents();
assertEventCount(events, 1);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testEvents() {
ThreadContext.put("loginId", "JohnDoe");
ThreadContext.put("ipAddress", "192.168.0.120");
ThreadContext.put("locale", Locale.US.getDisplayName());
final TransferMessage msg = new TransferMessage();
msg.put("ToAccount", "123456");
msg.put("FromAccount", "123457");
msg.put("Amount", "200.00");
EventLogger.logEvent(msg);
msg.setCompletionStatus("Transfer Complete");
EventLogger.logEvent(msg);
ThreadContext.clearMap();
// TODO: do something with the results
}
内容来源于网络,如有侵权,请联系作者删除!