本文整理汇总了Java中java.text.spi.DateFormatProvider类的典型用法代码示例。如果您正苦于以下问题:Java DateFormatProvider类的具体用法?Java DateFormatProvider怎么用?Java DateFormatProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DateFormatProvider类属于java.text.spi包,在下文中一共展示了DateFormatProvider类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import java.text.spi.DateFormatProvider; //导入依赖的package包/类
/**
* Creates a DateFormat with the given time and/or date style in the given
* locale.
* @param timeStyle a value from 0 to 3 indicating the time format,
* ignored if flags is 2
* @param dateStyle a value from 0 to 3 indicating the time format,
* ignored if flags is 1
* @param flags either 1 for a time format, 2 for a date format,
* or 3 for a date/time format
* @param loc the locale for the format
*/
private static DateFormat get(int timeStyle, int dateStyle,
int flags, Locale loc) {
if ((flags & 1) != 0) {
if (timeStyle < 0 || timeStyle > 3) {
throw new IllegalArgumentException("Illegal time style " + timeStyle);
}
} else {
timeStyle = -1;
}
if ((flags & 2) != 0) {
if (dateStyle < 0 || dateStyle > 3) {
throw new IllegalArgumentException("Illegal date style " + dateStyle);
}
} else {
dateStyle = -1;
}
LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
DateFormat dateFormat = get(adapter, timeStyle, dateStyle, loc);
if (dateFormat == null) {
dateFormat = get(LocaleProviderAdapter.forJRE(), timeStyle, dateStyle, loc);
}
return dateFormat;
}
示例2: getDateFormatProvider
import java.text.spi.DateFormatProvider; //导入依赖的package包/类
@Override
public DateFormatProvider getDateFormatProvider() {
if (dateFormatProvider == null) {
DateFormatProvider provider = AccessController.doPrivileged(
(PrivilegedAction<DateFormatProvider>) () ->
new DateFormatProviderImpl(
getAdapterType(),
getLanguageTagSet("FormatData")));
synchronized (this) {
if (dateFormatProvider == null) {
dateFormatProvider = provider;
}
}
}
return dateFormatProvider;
}
示例3: getObject
import java.text.spi.DateFormatProvider; //导入依赖的package包/类
public DateFormat getObject(DateFormatProvider dateFormatProvider,
Locale locale,
String key,
Object... params) {
assert params.length == 3;
int timeStyle = (Integer)params[0];
int dateStyle = (Integer)params[1];
int flags = (Integer)params[2];
switch (flags) {
case 1:
return dateFormatProvider.getTimeInstance(timeStyle, locale);
case 2:
return dateFormatProvider.getDateInstance(dateStyle, locale);
case 3:
return dateFormatProvider.getDateTimeInstance(dateStyle, timeStyle, locale);
default:
assert false : "should not happen";
}
return null;
}
示例4: getObject
import java.text.spi.DateFormatProvider; //导入依赖的package包/类
public DateFormat getObject(DateFormatProvider dateFormatProvider,
Locale locale,
String key,
Object... params) {
assert params.length == 3;
int timeStyle = (Integer)params[0];
int dateStyle = (Integer)params[1];
int flags = (Integer)params[2];
switch (flags) {
case 1:
return dateFormatProvider.getTimeInstance(timeStyle, locale);
case 2:
return dateFormatProvider.getDateInstance(dateStyle, locale);
case 3:
return dateFormatProvider.getDateTimeInstance(dateStyle, timeStyle, locale);
default:
assert false : "should not happen";
}
return null;
}
示例5: getDateFormatProvider
import java.text.spi.DateFormatProvider; //导入依赖的package包/类
@Override
public DateFormatProvider getDateFormatProvider() {
if (dateFormatProvider == null) {
DateFormatProvider provider = new DateFormatProviderImpl(getAdapterType(),
getLanguageTagSet("FormatData"));
synchronized (this) {
if (dateFormatProvider == null) {
dateFormatProvider = provider;
}
}
}
return dateFormatProvider;
}
示例6: getDefaultPattern
import java.text.spi.DateFormatProvider; //导入依赖的package包/类
private static String getDefaultPattern(Locale loc) {
LocaleProviderAdapter adapter = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, loc);
LocaleResources lr = adapter.getLocaleResources(loc);
if (lr == null) {
lr = LocaleProviderAdapter.forJRE().getLocaleResources(loc);
}
return lr.getDateTimePattern(DateFormat.SHORT, DateFormat.SHORT, null);
}
示例7: TestThread
import java.text.spi.DateFormatProvider; //导入依赖的package包/类
public TestThread() {
int which = count++ % 3;
switch (which) {
case 0 : cls = LocaleNameProvider.class; break;
case 1 : cls = TimeZoneNameProvider.class; break;
case 2 : cls = DateFormatProvider.class; break;
default : throw new AssertionError("Should not reach here");
}
}