本文整理汇总了Java中java.text.spi.DateFormatProvider.getAvailableLocales方法的典型用法代码示例。如果您正苦于以下问题:Java DateFormatProvider.getAvailableLocales方法的具体用法?Java DateFormatProvider.getAvailableLocales怎么用?Java DateFormatProvider.getAvailableLocales使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.text.spi.DateFormatProvider
的用法示例。
在下文中一共展示了DateFormatProvider.getAvailableLocales方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDateInstance
import java.text.spi.DateFormatProvider; //导入方法依赖的package包/类
/**
* This method returns an instance of <code>DateFormat</code> that will
* format using the specified formatting style for dates. 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 getDateInstance (int style, Locale loc)
{
try
{
return computeInstance (style, loc, true, false);
}
catch (MissingResourceException e)
{
for (DateFormatProvider p :
ServiceLoader.load(DateFormatProvider.class))
{
for (Locale l : p.getAvailableLocales())
{
if (l.equals(loc))
{
DateFormat df = p.getDateInstance(style, loc);
if (df != null)
return df;
break;
}
}
}
return getDateInstance(style,
LocaleHelper.getFallbackLocale(loc));
}
}
示例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: 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));
}
}
示例4: getDateInstance
import java.text.spi.DateFormatProvider; //导入方法依赖的package包/类
/**
* This method returns an instance of <code>DateFormat</code> that will
* format using the specified formatting style for dates. 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 getDateInstance (int style, Locale loc)
{
try
{
return computeInstance (style, loc, true, false);
}
catch (MissingResourceException e)
{
for (DateFormatProvider p :
ServiceLoader.load(DateFormatProvider.class))
{
for (Locale l : p.getAvailableLocales())
{
if (l.equals(loc))
{
DateFormat df = p.getDateInstance(style, loc);
if (df != null)
return df;
break;
}
}
}
return getDateInstance(style,
LocaleHelper.getFallbackLocale(loc));
}
}
示例5: 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));
}
}
示例6: 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));
}
}
示例7: addImpl
import java.text.spi.DateFormatProvider; //导入方法依赖的package包/类
@Override
public void addImpl(DateFormatProvider impl) {
for (Locale l : impl.getAvailableLocales()) {
map.putIfAbsent(l, impl);
}
}