本文整理汇总了Java中java.text.spi.DateFormatProvider.getDateTimeInstance方法的典型用法代码示例。如果您正苦于以下问题:Java DateFormatProvider.getDateTimeInstance方法的具体用法?Java DateFormatProvider.getDateTimeInstance怎么用?Java DateFormatProvider.getDateTimeInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.text.spi.DateFormatProvider
的用法示例。
在下文中一共展示了DateFormatProvider.getDateTimeInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: get
import java.text.spi.DateFormatProvider; //导入方法依赖的package包/类
private static DateFormat get(LocaleProviderAdapter adapter, int timeStyle, int dateStyle, Locale loc) {
DateFormatProvider provider = adapter.getDateFormatProvider();
DateFormat dateFormat;
if (timeStyle == -1) {
dateFormat = provider.getDateInstance(dateStyle, loc);
} else {
if (dateStyle == -1) {
dateFormat = provider.getTimeInstance(timeStyle, loc);
} else {
dateFormat = provider.getDateTimeInstance(dateStyle, timeStyle, loc);
}
}
return dateFormat;
}
示例2: getDateTimeInstance
import java.text.spi.DateFormatProvider; //导入方法依赖的package包/类
/**
* This method returns a new instance of <code>DateFormat</code> that
* formats both dates and times using the specified styles.
*
* @param dateStyle The desired style for date formatting.
* @param timeStyle The desired style for time formatting
*
* @return A new <code>DateFormat</code>instance.
*/
public static final DateFormat getDateTimeInstance (int dateStyle,
int timeStyle,
Locale loc)
{
try
{
return computeInstance (dateStyle, timeStyle, loc, true, true);
}
catch (MissingResourceException e)
{
for (DateFormatProvider p :
ServiceLoader.load(DateFormatProvider.class))
{
for (Locale l : p.getAvailableLocales())
{
if (l.equals(loc))
{
DateFormat df = p.getDateTimeInstance(dateStyle,
timeStyle, loc);
if (df != null)
return df;
break;
}
}
}
return getDateTimeInstance(dateStyle, timeStyle,
LocaleHelper.getFallbackLocale(loc));
}
}
示例3: getDateTimeInstance
import java.text.spi.DateFormatProvider; //导入方法依赖的package包/类
/**
* This method returns a new instance of <code>DateFormat</code> that
* formats both dates and times using the specified styles.
*
* @param dateStyle The desired style for date formatting.
* @param timeStyle The desired style for time formatting
*
* @return A new <code>DateFormat</code>instance.
*/
public static final DateFormat getDateTimeInstance (int dateStyle,
int timeStyle,
Locale loc)
{
try
{
return computeInstance (dateStyle, timeStyle, loc, true, true);
}
catch (MissingResourceException e)
{
for (DateFormatProvider p :
ServiceLoader.load(DateFormatProvider.class))
{
for (Locale l : p.getAvailableLocales())
{
if (l.equals(loc))
{
DateFormat df = p.getDateTimeInstance(dateStyle,
timeStyle, loc);
if (df != null)
return df;
break;
}
}
}
return getDateTimeInstance(dateStyle, timeStyle,
LocaleHelper.getFallbackLocale(loc));
}
}