/** * {@icu} Creates a {@link DateFormat} object that can be used to format dates and * times in the calendar system specified by <code>cal</code>. * * @param cal The calendar system for which a date/time format is desired. * * @param skeleton The skeleton that selects the fields to be formatted. (Uses the * {@link DateTimePatternGenerator}.) This can be * {@link DateFormat#ABBR_MONTH}, {@link DateFormat#MONTH_WEEKDAY_DAY}, * etc. * * @param locale The locale for which the date/time format is desired. * * @stable ICU 54 */ public final static DateFormat getInstanceForSkeleton( Calendar cal, String skeleton, ULocale locale) { DateTimePatternGenerator generator = DateTimePatternGenerator.getInstance(locale); final String bestPattern = generator.getBestPattern(skeleton); SimpleDateFormat format = new SimpleDateFormat(bestPattern, locale); format.setCalendar(cal); return format; }
public IValue printTime(IDateTime inputTime) //@doc{Print an input time using a default format string} { SimpleDateFormat sd = new SimpleDateFormat("HH:mm:ss.SSSZ"); Calendar cal = getCalendarForTime(inputTime); sd.setCalendar(cal); return values.string(sd.format(cal.getTime())); }
public IValue printDateTime(IDateTime inputDateTime) //@doc{Print an input datetime using a default format string} { SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ"); Calendar cal = getCalendarForDateTime(inputDateTime); sd.setCalendar(cal); return values.string(sd.format(cal.getTime())); }
public IValue printDate(IDateTime inputDate) //@doc{Print an input date using a default format string} { SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = getCalendarForDate(inputDate); sd.setCalendar(cal); return values.string(sd.format(cal.getTime())); }
icuCal.setMinimalDaysInFirstWeek(newCalendar.getMinimalDaysInFirstWeek()); fIcuSdf.setCalendar(icuCal);
public IValue printDate(IDateTime inputDate, IString formatString) //@doc{Print an input date using the given format string} { try { SimpleDateFormat sd = new SimpleDateFormat(formatString.getValue()); Calendar cal = getCalendarForDate(inputDate); sd.setCalendar(cal); return values.string(sd.format(cal.getTime())); } catch (IllegalArgumentException iae) { throw RuntimeExceptionFactory.dateTimePrintingError("Cannot print date " + inputDate + " with format " + formatString.getValue(), null, null); } }
public IValue printDateTime(IDateTime inputDateTime, IString formatString) //@doc{Print an input datetime using the given format string} { try { SimpleDateFormat sd = new SimpleDateFormat(formatString.getValue()); Calendar cal = getCalendarForDateTime(inputDateTime); sd.setCalendar(cal); return values.string(sd.format(cal.getTime())); } catch (IllegalArgumentException iae) { throw RuntimeExceptionFactory.dateTimePrintingError("Cannot print datetime " + inputDateTime + " using format string: " + formatString.getValue(), null, null); } }
public IValue printTime(IDateTime inputTime, IString formatString) //@doc{Print an input time using the given format string} { try { SimpleDateFormat sd = new SimpleDateFormat(formatString.getValue()); Calendar cal = getCalendarForTime(inputTime); sd.setCalendar(cal); return values.string(sd.format(cal.getTime())); } catch (IllegalArgumentException iae) { throw RuntimeExceptionFactory.dateTimePrintingError("Cannot print time " + inputTime + " with format: " + formatString.getValue(), null, null); } }
public IValue printTimeInLocale(IDateTime inputTime, IString locale) //@doc{Print an input time using a specific locale and a default format string} { try { SimpleDateFormat sd = new SimpleDateFormat("HH:mm:ss.SSSZ",new ULocale(locale.getValue())); Calendar cal = getCalendarForTime(inputTime); sd.setCalendar(cal); return values.string(sd.format(cal.getTime())); } catch (IllegalArgumentException iae) { throw RuntimeExceptionFactory.dateTimePrintingError("Cannot print time " + inputTime + " in locale: " + locale.getValue(), null, null); } }
public IValue printDateInLocale(IDateTime inputDate, IString locale) //@doc{Print an input date using a specific locale and a default format string} { try { SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd",new ULocale(locale.getValue())); Calendar cal = getCalendarForDate(inputDate); sd.setCalendar(cal); return values.string(sd.format(cal.getTime())); } catch (IllegalArgumentException iae) { throw RuntimeExceptionFactory.dateTimePrintingError("Cannot print time " + inputDate + " in locale: " + locale.getValue(), null, null); } }
public IValue printDateTimeInLocale(IDateTime inputDateTime, IString locale) //@doc{Print an input datetime using a specific locale and a default format string} { try { SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ",new ULocale(locale.getValue())); Calendar cal = getCalendarForDateTime(inputDateTime); sd.setCalendar(cal); return values.string(sd.format(cal.getTime())); } catch (IllegalArgumentException iae) { throw RuntimeExceptionFactory.dateTimePrintingError("Cannot print datetime " + inputDateTime + " in locale: " + locale.getValue(), null, null); } }
public IValue printTimeInLocale(IDateTime inputTime, IString formatString, IString locale) //@doc{Print an input time using a specific locale and format string} { try { SimpleDateFormat sd = new SimpleDateFormat(formatString.getValue(),new ULocale(locale.getValue())); Calendar cal = getCalendarForTime(inputTime); sd.setCalendar(cal); return values.string(sd.format(cal.getTime())); } catch (IllegalArgumentException iae) { throw RuntimeExceptionFactory.dateTimePrintingError("Cannot print time " + inputTime + " in locale: " + locale.getValue(), null, null); } }
public IValue printDateInLocale(IDateTime inputDate, IString formatString, IString locale) //@doc{Print an input date using a specific locale and format string} { try { SimpleDateFormat sd = new SimpleDateFormat(formatString.getValue(),new ULocale(locale.getValue())); Calendar cal = getCalendarForDate(inputDate); sd.setCalendar(cal); return values.string(sd.format(cal.getTime())); } catch (IllegalArgumentException iae) { throw RuntimeExceptionFactory.dateTimePrintingError("Cannot print date " + inputDate + " with format " + formatString.getValue() + ", in locale: " + locale.getValue(), null, null); } }
public IValue printDateTimeInLocale(IDateTime inputDateTime, IString formatString, IString locale) //@doc{Print an input datetime using a specific locale and format string} { try { SimpleDateFormat sd = new SimpleDateFormat(formatString.getValue(),new ULocale(locale.getValue())); Calendar cal = getCalendarForDateTime(inputDateTime); sd.setCalendar(cal); return values.string(sd.format(cal.getTime())); } catch (IllegalArgumentException iae) { throw RuntimeExceptionFactory.dateTimePrintingError("Cannot print datetime " + inputDateTime + " using format string: " + formatString.getValue() + " in locale: " + locale.getValue(), null, null); } }