本文整理汇总了Java中com.ibm.icu.text.DateFormat.getTimeInstance方法的典型用法代码示例。如果您正苦于以下问题:Java DateFormat.getTimeInstance方法的具体用法?Java DateFormat.getTimeInstance怎么用?Java DateFormat.getTimeInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.text.DateFormat
的用法示例。
在下文中一共展示了DateFormat.getTimeInstance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: guessDateFormat
import com.ibm.icu.text.DateFormat; //导入方法依赖的package包/类
/**
* This function can be overridden by subclasses to use different heuristics.
* <b>It MUST return a 'safe' value,
* one whose modification will not affect this object.</b>
*
* @param dateStyle
* @param timeStyle
* @draft ICU 3.6
* @provisional This API might change or be removed in a future release.
*/
protected DateFormat guessDateFormat(int dateStyle, int timeStyle) {
DateFormat result;
ULocale dfLocale = getAvailableLocale(TYPE_DATEFORMAT);
if (dfLocale == null) {
dfLocale = ULocale.ROOT;
}
if (timeStyle == DF_NONE) {
result = DateFormat.getDateInstance(getCalendar(), dateStyle, dfLocale);
} else if (dateStyle == DF_NONE) {
result = DateFormat.getTimeInstance(getCalendar(), timeStyle, dfLocale);
} else {
result = DateFormat.getDateTimeInstance(getCalendar(), dateStyle, timeStyle, dfLocale);
}
return result;
}
示例2: get
import com.ibm.icu.text.DateFormat; //导入方法依赖的package包/类
@Override
public ImmutableList<DateFormat> get(Placeholder target, ULocale locale) {
ImmutableList.Builder<DateFormat> result = ImmutableList.builder();
for (Integer type : FORMATS) {
DateFormat dateFormat = DateFormat.getTimeInstance(type, locale);
dateFormat.setLenient(target.isLenient());
result.add(dateFormat);
}
return result.build();
}
示例3: defaultHourFormat
import com.ibm.icu.text.DateFormat; //导入方法依赖的package包/类
/**
* Retrieve the default hour format character for the supplied locale.
*
* @param locale
* the locale
* @return the hour format character
* @see <a href="http://bugs.icu-project.org/trac/ticket/9997">ICU bug 9997</a>
*/
private static char defaultHourFormat(ULocale locale) {
// Use short time format, just as ICU4J does internally. And as suggested in
// <http://unicode.org/reports/tr35/tr35-dates.html#availableFormats_appendItems>.
SimpleDateFormat df = (SimpleDateFormat) DateFormat.getTimeInstance(DateFormat.SHORT, locale);
Skeleton skeleton = Skeleton.fromPattern(df.toPattern());
if (skeleton.has(DateField.Hour)) {
return skeleton.getSymbol(DateField.Hour);
}
return 'H';
}
示例4: formatCalTimeOnly
import com.ibm.icu.text.DateFormat; //导入方法依赖的package包/类
public String formatCalTimeOnly(final Calendar cal, final int timeFormat) {
DateFormat df = DateFormat.getTimeInstance(transTimeFormat(timeFormat), iLocale);
df.setCalendar(cal);
return df.format(cal.getTime());
}