protected String expandDate(String date) throws ParseException { // date format is "month/day/year" Date humanDate = df.getPatternInstance("MM.dd.yyyy", ULocale.ENGLISH).parse(date); String[] dateParts = df.format(humanDate).replaceAll(",", "").split("\\s"); dateParts[1] = expandOrdinal(Double.parseDouble(dateParts[1])); dateParts[2] = expandYear(Double.parseDouble(dateParts[2])); return Arrays.toString(dateParts).replaceAll("[,\\]\\[]", ""); }
/** * {@icu} Returns a {@link DateFormat} object that can be used to format dates and times in * the default locale. * * @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. * * @stable ICU 54 */ public final static DateFormat getInstanceForSkeleton(String skeleton) { return getPatternInstance(skeleton, ULocale.getDefault(Category.FORMAT)); }
/** * {@icu} Returns a {@link DateFormat} object that can be used to format dates and times in * the given locale. * * @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(String skeleton, Locale locale) { return getPatternInstance(skeleton, ULocale.forLocale(locale)); }
/** * {@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, Locale locale) { return getPatternInstance(cal, skeleton, ULocale.forLocale(locale)); }
@Override public String formatDate(String locale, Date date, String skeleton, String timezone) { ULocale closestLocale = localeService.getClosestULocale(locale); DateFormat formatter = DateFormat.getPatternInstance(skeleton, closestLocale); if (StringUtils.isNotEmpty(timezone)) { formatter.setTimeZone(TimeZone.getTimeZone(timezone)); } return formatter.format(date); }
@Override public Date parseDate(String locale, String value, String skeleton, String timezone) throws ParseException { ULocale closestLocale = findClosestULocale(locale); DateFormat formatter = DateFormat.getPatternInstance(skeleton, closestLocale); if (StringUtils.isNotEmpty(timezone)) { formatter.setTimeZone(TimeZone.getTimeZone(timezone)); } return formatter.parse(value); }
return DateFormat.getPatternInstance(pattern, context.get().getLocale());
@Override public Date parseDate(String locale, String value, String skeleton, String timezone) throws ParseException { ULocale closestLocale = localeService.getClosestULocale(locale); DateFormat formatter = DateFormat.getPatternInstance(skeleton, closestLocale); if (StringUtils.isNotEmpty(timezone)) { formatter.setTimeZone(TimeZone.getTimeZone(timezone)); } return formatter.parse(value); }
@Override public String formatDate(String locale, Date date, String skeleton, String timezone) { ULocale closestLocale = findClosestULocale(locale); DateFormat formatter = DateFormat.getPatternInstance(skeleton, closestLocale); if (StringUtils.isNotEmpty(timezone)) { formatter.setTimeZone(TimeZone.getTimeZone(timezone)); } return formatter.format(date); }