本文整理了Java中java.text.DateFormat.getAvailableLocales()
方法的一些代码示例,展示了DateFormat.getAvailableLocales()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DateFormat.getAvailableLocales()
方法的具体详情如下:
包路径:java.text.DateFormat
类名称:DateFormat
方法名:getAvailableLocales
[英]Returns an array of locales for which custom DateFormat instances are available.
Note that Android does not support user-supplied locale service providers.
[中]返回可用于自定义DateFormat实例的区域设置数组。
请注意,Android不支持用户提供的区域设置服务提供商。
代码示例来源:origin: org.apache.commons/commons-lang3
testLocales.addAll(Arrays.asList(DateFormat.getAvailableLocales()));
testLocales.retainAll(Arrays.asList(NumberFormat.getAvailableLocales()));
testLocales.add(null);
代码示例来源:origin: org.apache.commons/commons-lang3
@Test
public void testOverriddenBuiltinFormat() {
final Calendar cal = Calendar.getInstance();
cal.set(2007, Calendar.JANUARY, 23);
final Object[] args = new Object[] {cal.getTime()};
final Locale[] availableLocales = DateFormat.getAvailableLocales();
final Map<String, ? extends FormatFactory> dateRegistry = Collections.singletonMap("date", new OverrideShortDateFormatFactory());
//check the non-overridden builtins:
checkBuiltInFormat("1: {0,date}", dateRegistry, args, availableLocales);
checkBuiltInFormat("2: {0,date,medium}", dateRegistry, args, availableLocales);
checkBuiltInFormat("3: {0,date,long}", dateRegistry, args, availableLocales);
checkBuiltInFormat("4: {0,date,full}", dateRegistry, args, availableLocales);
checkBuiltInFormat("5: {0,date,d MMM yy}", dateRegistry, args, availableLocales);
//check the overridden format:
for (int i = -1; i < availableLocales.length; i++) {
final Locale locale = i < 0 ? null : availableLocales[i];
final MessageFormat dateDefault = createMessageFormat("{0,date}", locale);
final String pattern = "{0,date,short}";
final ExtendedMessageFormat dateShort = new ExtendedMessageFormat(pattern, locale, dateRegistry);
assertEquals("overridden date,short format", dateDefault.format(args), dateShort.format(args));
assertEquals("overridden date,short pattern", pattern, dateShort.toPattern());
}
}
代码示例来源:origin: org.apache.commons/commons-lang3
/**
* Test the built in date/time formats
*/
@Test
public void testBuiltInDateTimeFormat() {
final Calendar cal = Calendar.getInstance();
cal.set(2007, Calendar.JANUARY, 23, 18, 33, 5);
final Object[] args = new Object[] {cal.getTime()};
final Locale[] availableLocales = DateFormat.getAvailableLocales();
checkBuiltInFormat("1: {0,date,short}", args, availableLocales);
checkBuiltInFormat("2: {0,date,medium}", args, availableLocales);
checkBuiltInFormat("3: {0,date,long}", args, availableLocales);
checkBuiltInFormat("4: {0,date,full}", args, availableLocales);
checkBuiltInFormat("5: {0,date,d MMM yy}", args, availableLocales);
checkBuiltInFormat("6: {0,time,short}", args, availableLocales);
checkBuiltInFormat("7: {0,time,medium}", args, availableLocales);
checkBuiltInFormat("8: {0,time,long}", args, availableLocales);
checkBuiltInFormat("9: {0,time,full}", args, availableLocales);
checkBuiltInFormat("10: {0,time,HH:mm}", args, availableLocales);
checkBuiltInFormat("11: {0,date}", args, availableLocales);
checkBuiltInFormat("12: {0,time}", args, availableLocales);
}
代码示例来源:origin: org.apache.commons/commons-text
testLocales.addAll(Arrays.asList(DateFormat.getAvailableLocales()));
testLocales.retainAll(Arrays.asList(NumberFormat.getAvailableLocales()));
testLocales.add(null);
代码示例来源:origin: at.bestsolution.eclipse/com.ibm.icu.base
/**
* Returns the set of locales for which DateFormats are installed.
* @return the set of locales for which DateFormats are installed.
* @stable ICU 2.0
*/
public static Locale[] getAvailableLocales()
{
return java.text.DateFormat.getAvailableLocales();
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.ibm.icu.base
/**
* Returns the set of locales for which DateFormats are installed.
* @return the set of locales for which DateFormats are installed.
* @stable ICU 2.0
*/
public static Locale[] getAvailableLocales()
{
return java.text.DateFormat.getAvailableLocales();
}
代码示例来源:origin: ThreeTen/threetenbp
@Override
public Locale[] getAvailableLocales() {
return DateFormat.getAvailableLocales();
}
代码示例来源:origin: EvoSuite/evosuite
public static synchronized Locale[] getAvailableLocales(){
//TODO do we need to mock it?
return DateFormat.getAvailableLocales();
}
代码示例来源:origin: EvoSuite/evosuite
public static Locale[] getAvailableLocales() {
return DateFormat.getAvailableLocales();
}
}
代码示例来源:origin: org.threeten/threetenbp
@Override
public Locale[] getAvailableLocales() {
return DateFormat.getAvailableLocales();
}
代码示例来源:origin: de.alpharogroup/resourcebundle-inspector
/**
* Resolve available locales on the current system.
*
* @return the list with the available locales.
*/
public List<Locale> resolveAvailableLocales()
{
return Arrays.asList(DateFormat.getAvailableLocales());
}
代码示例来源:origin: stackoverflow.com
Locale[] locales = SimpleDateFormat.getAvailableLocales();
for (int i = 0; i < locales.length; i++) {
Locale locale = locales[i];
DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL, locale);
}
代码示例来源:origin: stackoverflow.com
list of supported locale.
Locale locales[] = SimpleDateFormat.getAvailableLocales();
for (int i = 0; i < locales.length; i++) {
System.out.printf("%10s - %s, %s \n" , locales[i].toString(),locales[i].getDisplayName(), locales[i].getDisplayCountry());
}
代码示例来源:origin: org.apache.commons/commons-text
@Test
public void testOverriddenBuiltinFormat() {
final Calendar cal = Calendar.getInstance();
cal.set(2007, Calendar.JANUARY, 23);
final Object[] args = new Object[] {cal.getTime()};
final Locale[] availableLocales = DateFormat.getAvailableLocales();
final Map<String, ? extends FormatFactory> dateRegistry =
Collections.singletonMap("date", new OverrideShortDateFormatFactory());
//check the non-overridden builtins:
checkBuiltInFormat("1: {0,date}", dateRegistry, args, availableLocales);
checkBuiltInFormat("2: {0,date,medium}", dateRegistry, args, availableLocales);
checkBuiltInFormat("3: {0,date,long}", dateRegistry, args, availableLocales);
checkBuiltInFormat("4: {0,date,full}", dateRegistry, args, availableLocales);
checkBuiltInFormat("5: {0,date,d MMM yy}", dateRegistry, args, availableLocales);
//check the overridden format:
for (int i = -1; i < availableLocales.length; i++) {
final Locale locale = i < 0 ? null : availableLocales[i];
final MessageFormat dateDefault = createMessageFormat("{0,date}", locale);
final String pattern = "{0,date,short}";
final ExtendedMessageFormat dateShort = new ExtendedMessageFormat(pattern, locale, dateRegistry);
assertEquals(dateDefault.format(args), dateShort.format(args), "overridden date,short format");
assertEquals(pattern, dateShort.toPattern(), "overridden date,short pattern");
}
}
代码示例来源:origin: stackoverflow.com
static public void main(String[]args) {
Locale al[] = DateFormat.getAvailableLocales();
for (Locale l : al) {
System.out.println(l);
}
}
代码示例来源:origin: stackoverflow.com
for (Locale locale : DateFormat.getAvailableLocales()) {
for (int style = DateFormat.FULL; style <= DateFormat.SHORT; style ++) {
DateFormat df = DateFormat.getDateInstance(style, locale);
try {
df.parse(dateString);
// either return "true", or return the Date obtained Date object
} catch (ParseException ex) {
continue; // unperasable, try the next one
}
}
}
代码示例来源:origin: org.apache.commons/commons-text
/**
* Test the built in date/time formats
*/
@Test
public void testBuiltInDateTimeFormat() {
final Calendar cal = Calendar.getInstance();
cal.set(2007, Calendar.JANUARY, 23, 18, 33, 5);
final Object[] args = new Object[] {cal.getTime()};
final Locale[] availableLocales = DateFormat.getAvailableLocales();
checkBuiltInFormat("1: {0,date,short}", args, availableLocales);
checkBuiltInFormat("2: {0,date,medium}", args, availableLocales);
checkBuiltInFormat("3: {0,date,long}", args, availableLocales);
checkBuiltInFormat("4: {0,date,full}", args, availableLocales);
checkBuiltInFormat("5: {0,date,d MMM yy}", args, availableLocales);
checkBuiltInFormat("6: {0,time,short}", args, availableLocales);
checkBuiltInFormat("7: {0,time,medium}", args, availableLocales);
checkBuiltInFormat("8: {0,time,long}", args, availableLocales);
checkBuiltInFormat("9: {0,time,full}", args, availableLocales);
checkBuiltInFormat("10: {0,time,HH:mm}", args, availableLocales);
checkBuiltInFormat("11: {0,date}", args, availableLocales);
checkBuiltInFormat("12: {0,time}", args, availableLocales);
}
代码示例来源:origin: stackoverflow.com
Locale[] locales = DateFormat.getAvailableLocales();
for (Locale locale : locales) {
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
if (df instanceof SimpleDateFormat) { // For the time being it will always be...
SimpleDateFormat sdf = (SimpleDateFormat) df;
System.out.println(sdf.toPattern());
}
}
代码示例来源:origin: stackoverflow.com
Locale.setDefault(new Locale("ES"));
Locale[] locales = SimpleDateFormat.getAvailableLocales();
for(Locale l : locales) {
System.out.println(l.getDisplayName());
}
代码示例来源:origin: EvoSuite/evosuite
public static Locale[] getAvailableLocales()
{
Capturer.capture(Instrumenter.CAPTURE_ID_JAVA_TEXT_DATEFORMAT, CaptureUtil.loadClass("java/text/DateFormat"), "getAvailableLocales", "()[Ljava/util/Locale;", new Object[] {});
Locale[] ret = java.text.DateFormat.getAvailableLocales();
FieldRegistry.register(ret);
Capturer.enable(Instrumenter.CAPTURE_ID_JAVA_TEXT_DATEFORMAT, CaptureUtil.loadClass("java/text/DateFormat"), ret);
return ret;
}
内容来源于网络,如有侵权,请联系作者删除!