本文整理汇总了Java中com.ibm.icu.text.DateFormat.SHORT属性的典型用法代码示例。如果您正苦于以下问题:Java DateFormat.SHORT属性的具体用法?Java DateFormat.SHORT怎么用?Java DateFormat.SHORT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.ibm.icu.text.DateFormat
的用法示例。
在下文中一共展示了DateFormat.SHORT属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJavaType
/**
*
* @return
* @throws UndefinedValueException
*/
private final int getJavaType( ) throws ChartException
{
switch ( getType( ).getValue( ) )
{
case DateFormatType.SHORT :
return DateFormat.SHORT;
case DateFormatType.MEDIUM :
return DateFormat.MEDIUM;
case DateFormatType.LONG :
return DateFormat.LONG;
case DateFormatType.FULL :
return DateFormat.FULL;
}
return 0;
}
示例2: initializeCombinedFormat
private MessageFormat initializeCombinedFormat(Calendar cal, ULocale locale) {
String pattern;
ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle.getBundleInstance(
ICUData.ICU_BASE_NAME, locale);
String resourcePath = "calendar/" + cal.getType() + "/DateTimePatterns";
ICUResourceBundle patternsRb= rb.findWithFallback(resourcePath);
if (patternsRb == null && !cal.getType().equals("gregorian")) {
// Try again with gregorian, if not already attempted.
patternsRb = rb.findWithFallback("calendar/gregorian/DateTimePatterns");
}
if (patternsRb == null || patternsRb.getSize() < 9) {
// Undefined or too few elements.
pattern = "{1} {0}";
} else {
int glueIndex = 8;
if (patternsRb.getSize() >= 13) {
if (fDateStyle >= DateFormat.FULL && fDateStyle <= DateFormat.SHORT) {
glueIndex += fDateStyle + 1;
} else
if (fDateStyle >= DateFormat.RELATIVE_FULL &&
fDateStyle <= DateFormat.RELATIVE_SHORT) {
glueIndex += fDateStyle + 1 - DateFormat.RELATIVE;
}
}
int elementType = patternsRb.get(glueIndex).getType();
if (elementType == UResourceBundle.ARRAY) {
pattern = patternsRb.get(glueIndex).getString(0);
} else {
pattern = patternsRb.getString(glueIndex);
}
}
combinedFormatHasDateAtStart = pattern.startsWith("{1}");
fCombinedFormat = new MessageFormat(pattern, locale);
return fCombinedFormat;
}
示例3: transTimeFormat
private int transTimeFormat(final int timeFormat) {
if (timeFormat == TIMEFORMAT_MEDIUM)
return DateFormat.MEDIUM;
if (timeFormat == TIMEFORMAT_SHORT)
return DateFormat.SHORT;
return DateFormat.LONG;
}
示例4: formatHelper
static private DateFormat formatHelper(Calendar cal, ULocale loc, int dateStyle,
int timeStyle) {
if (timeStyle < DateFormat.NONE || timeStyle > DateFormat.SHORT) {
throw new IllegalArgumentException("Illegal time style " + timeStyle);
}
if (dateStyle < DateFormat.NONE || dateStyle > DateFormat.SHORT) {
throw new IllegalArgumentException("Illegal date style " + dateStyle);
}
PatternData patternData = PatternData.make(cal, loc);
String override = null;
// Resolve a pattern for the date/time style
String pattern = null;
if ((timeStyle >= 0) && (dateStyle >= 0)) {
pattern = SimpleFormatterImpl.formatRawPattern(
patternData.getDateTimePattern(dateStyle), 2, 2,
patternData.patterns[timeStyle],
patternData.patterns[dateStyle + 4]);
// Might need to merge the overrides from the date and time into a single
// override string TODO: Right now we are forcing the date's override into the
// time style.
if ( patternData.overrides != null ) {
String dateOverride = patternData.overrides[dateStyle + 4];
String timeOverride = patternData.overrides[timeStyle];
override = mergeOverrideStrings(
patternData.patterns[dateStyle+4],
patternData.patterns[timeStyle],
dateOverride, timeOverride);
}
} else if (timeStyle >= 0) {
pattern = patternData.patterns[timeStyle];
if ( patternData.overrides != null ) {
override = patternData.overrides[timeStyle];
}
} else if (dateStyle >= 0) {
pattern = patternData.patterns[dateStyle + 4];
if ( patternData.overrides != null ) {
override = patternData.overrides[dateStyle + 4];
}
} else {
throw new IllegalArgumentException("No date or time style specified");
}
DateFormat result = cal.handleGetDateFormat(pattern, override, loc);
result.setCalendar(cal);
return result;
}