本文整理汇总了Java中java.text.spi.DateFormatProvider.getTimeInstance方法的典型用法代码示例。如果您正苦于以下问题:Java DateFormatProvider.getTimeInstance方法的具体用法?Java DateFormatProvider.getTimeInstance怎么用?Java DateFormatProvider.getTimeInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.text.spi.DateFormatProvider
的用法示例。
在下文中一共展示了DateFormatProvider.getTimeInstance方法的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: getTimeInstance
import java.text.spi.DateFormatProvider; //导入方法依赖的package包/类
/**
* This method returns an instance of <code>DateFormat</code> that will
* format using the specified formatting style for times. The specified
* localed will be used in place of the default.
*
* @param style The type of formatting to perform.
* @param loc The desired locale.
*
* @return A new <code>DateFormat</code> instance.
*/
public static final DateFormat getTimeInstance (int style, Locale loc)
{
try
{
return computeInstance (style, loc, false, true);
}
catch (MissingResourceException e)
{
for (DateFormatProvider p :
ServiceLoader.load(DateFormatProvider.class))
{
for (Locale l : p.getAvailableLocales())
{
if (l.equals(loc))
{
DateFormat df = p.getTimeInstance(style, loc);
if (df != null)
return df;
break;
}
}
}
return getTimeInstance(style,
LocaleHelper.getFallbackLocale(loc));
}
}
示例3: getTimeInstance
import java.text.spi.DateFormatProvider; //导入方法依赖的package包/类
/**
* This method returns an instance of <code>DateFormat</code> that will
* format using the specified formatting style for times. The specified
* localed will be used in place of the default.
*
* @param style The type of formatting to perform.
* @param loc The desired locale.
*
* @return A new <code>DateFormat</code> instance.
*/
public static final DateFormat getTimeInstance (int style, Locale loc)
{
try
{
return computeInstance (style, loc, false, true);
}
catch (MissingResourceException e)
{
for (DateFormatProvider p :
ServiceLoader.load(DateFormatProvider.class))
{
for (Locale l : p.getAvailableLocales())
{
if (l.equals(loc))
{
DateFormat df = p.getTimeInstance(style, loc);
if (df != null)
return df;
break;
}
}
}
return getTimeInstance(style,
LocaleHelper.getFallbackLocale(loc));
}
}