本文整理汇总了Java中com.ibm.icu.text.DateFormat.getDateTimeInstance方法的典型用法代码示例。如果您正苦于以下问题:Java DateFormat.getDateTimeInstance方法的具体用法?Java DateFormat.getDateTimeInstance怎么用?Java DateFormat.getDateTimeInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.text.DateFormat
的用法示例。
在下文中一共展示了DateFormat.getDateTimeInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 dateType : FORMATS) {
for (Integer timeType : FORMATS) {
if (dateType == timeType && dateType == DateFormat.NONE) {
continue;
}
DateFormat dateFormat = DateFormat.getDateTimeInstance(dateType, timeType, locale);
dateFormat.setLenient(target.isLenient());
result.add(dateFormat);
}
}
return result.build();
}
示例3: testCheck_Simple
import com.ibm.icu.text.DateFormat; //导入方法依赖的package包/类
@Test
public void testCheck_Simple() {
// TODO(antkrumin): Rewrite with mocks.
DateFormat dateFormat1 =
DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, ULocale.JAPAN);
DateFormat dateFormat2 =
DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.SHORT, ULocale.JAPAN);
String actualValue = dateFormat1.format(TestUtils.generateRandomDate()) + " :::: "
+ dateFormat2.format(TestUtils.generateRandomDate());
Placeholder testToken =
Placeholder.builder("date", actualValue).putSplitterParam("::::").build();
checker.check(testToken, ULocale.JAPAN, null);
}
示例4: testCheck_Short
import com.ibm.icu.text.DateFormat; //导入方法依赖的package包/类
@Test
public void testCheck_Short() {
DateFormat dateFormat1 =
DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, ULocale.US);
DateFormat dateFormat2 =
DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, ULocale.US);
String actualValue = dateFormat1.format(TestUtils.generateRandomDate()) + " - "
+ dateFormat2.format(TestUtils.generateRandomDate());
Placeholder testToken = Placeholder.builder("date", actualValue).build();
checker.check(testToken, ULocale.US, null);
}
示例5: testCheck_WordSplitter
import com.ibm.icu.text.DateFormat; //导入方法依赖的package包/类
@Test
public void testCheck_WordSplitter() {
DateFormat dateFormat1 =
DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, new ULocale("ml"));
DateFormat dateFormat2 =
DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, new ULocale("ml"));
String actualValue = dateFormat1.format(TestUtils.generateRandomDate()) + " till "
+ dateFormat2.format(TestUtils.generateRandomDate());
Placeholder testToken =
Placeholder.builder("date", actualValue).putSplitterParam("till").build();
checker.check(testToken, new ULocale("ml"), null);
}
示例6: formatCalDateTime
import com.ibm.icu.text.DateFormat; //导入方法依赖的package包/类
public String formatCalDateTime(final Calendar cal, final int timeFormat) {
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, transTimeFormat(timeFormat), iLocale);
df.setCalendar(cal);
return df.format(cal.getTime());
}