Java Code Examples for com.ibm.icu.text.DateFormat#getDateTimeInstance()

The following examples show how to use com.ibm.icu.text.DateFormat#getDateTimeInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GlobalizationPreferences.java    From fitnotifications with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: FormatterImpl.java    From org.openntf.domino with Apache License 2.0 4 votes vote down vote up
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());
}