Java Code Examples for com.ibm.icu.text.DateFormat#format()
The following examples show how to use
com.ibm.icu.text.DateFormat#format() .
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: DateFormatWrapperFactory.java From birt with Eclipse Public License 1.0 | 4 votes |
public String format( Date date ) { StringBuffer str = new StringBuffer( ); FieldPosition pos = new FieldPosition( DateFormat.DATE_FIELD ); DateFormat df = DateFormat.getDateInstance( DateFormat.MEDIUM, locale ); if ( tz != null ) { df.setTimeZone( tz ); } df.format( date, str, pos ); int endIndex; if ( pos.getEndIndex( ) >= str.length( ) ) { endIndex = pos.getEndIndex( ); } else { endIndex = pos.getEndIndex( ) + ( str.charAt( pos.getEndIndex( ) ) == ',' ? 2 : 1 ); } if ( endIndex >= str.length( ) ) // means date is the last one, need // to remove separator { endIndex = pos.getBeginIndex( ); while ( endIndex > 0 ) { char ch = str.charAt( endIndex - 1 ); if ( ch == ' ' || ch == ',' || ch == '/' || ch == '-' || ch == '.' ) { endIndex--; } else { break; } } return str.substring( 0, endIndex ); } return str.substring( 0, pos.getBeginIndex( ) ) + str.substring( endIndex ); }
Example 2
Source File: FormatterImpl.java From org.openntf.domino with Apache License 2.0 | 4 votes |
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()); }
Example 3
Source File: FormatterImpl.java From org.openntf.domino with Apache License 2.0 | 4 votes |
public String formatCalDateOnly(final Calendar cal) { DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, iLocale); df.setCalendar(cal); return df.format(cal.getTime()); }
Example 4
Source File: FormatterImpl.java From org.openntf.domino with Apache License 2.0 | 4 votes |
public String formatCalTimeOnly(final Calendar cal, final int timeFormat) { DateFormat df = DateFormat.getTimeInstance(transTimeFormat(timeFormat), iLocale); df.setCalendar(cal); return df.format(cal.getTime()); }
Example 5
Source File: DominoFormatter.java From org.openntf.domino with Apache License 2.0 | 3 votes |
/** * Gets the date only. * * @param date * the date * @return the date only */ public String getDateOnly(final Date date) { DateFormat df = getDateOnlyFormat(); synchronized (df) { return df.format(date); } }
Example 6
Source File: DominoFormatter.java From org.openntf.domino with Apache License 2.0 | 3 votes |
/** * Gets the time only. * * @param date * the date * @return the time only */ public String getTimeOnly(final Date date) { DateFormat df = getTimeOnlyFormat(); synchronized (df) { return df.format(date); } }
Example 7
Source File: DominoFormatter.java From org.openntf.domino with Apache License 2.0 | 3 votes |
/** * Gets the date time. * * @param date * the date * @return the date time */ public String getDateTime(final Date date) { DateFormat df = getDateTimeFormat(); synchronized (df) { return df.format(date); } }