use of android.icu.text.SimpleDateFormat in project j2objc by google.
the class TestMessageFormat method TestSetFormat.
@Test
public void TestSetFormat() {
MessageFormat ms = new MessageFormat("{number} {date}", ULocale.ENGLISH);
final DecimalFormat decimalFormat = new DecimalFormat("000.000", DecimalFormatSymbols.getInstance(ULocale.ENGLISH));
ms.setFormatByArgumentName("number", decimalFormat);
final SimpleDateFormat dateFormat = new SimpleDateFormat("'year:'yy 'month:'MM 'day:'dd");
dateFormat.setTimeZone(TimeZone.getTimeZone("Etc/GMT"));
ms.setFormatByArgumentName("date", dateFormat);
Map map = new HashMap();
map.put("number", new Integer(1234));
map.put("date", new Date(0, 0, 0));
String result = ms.format(map);
assertEquals("setFormatByArgumentName", "1234.000 year:99 month:12 day:31", result);
Set formatNames = ms.getArgumentNames();
assertEquals("Format Names match", formatNames, map.keySet());
assertEquals("Decimal", decimalFormat, ms.getFormatByArgumentName("number"));
assertEquals("Date", dateFormat, ms.getFormatByArgumentName("date"));
}
use of android.icu.text.SimpleDateFormat in project android_frameworks_base by AOSPA.
the class DatePickerCalendarDelegate method onPopulateAccessibilityEvent.
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
if (mAccessibilityEventFormat == null) {
final String pattern = DateFormat.getBestDateTimePattern(mCurrentLocale, "EMMMMdy");
mAccessibilityEventFormat = new SimpleDateFormat(pattern);
}
final CharSequence text = mAccessibilityEventFormat.format(mCurrentDate.getTime());
event.getText().add(text);
}
use of android.icu.text.SimpleDateFormat in project android_frameworks_base by ResurrectionRemix.
the class DatePickerCalendarDelegate method onPopulateAccessibilityEvent.
@Override
public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
if (mAccessibilityEventFormat == null) {
final String pattern = DateFormat.getBestDateTimePattern(mCurrentLocale, "EMMMMdy");
mAccessibilityEventFormat = new SimpleDateFormat(pattern);
}
final CharSequence text = mAccessibilityEventFormat.format(mCurrentDate.getTime());
event.getText().add(text);
}
use of android.icu.text.SimpleDateFormat in project android_frameworks_base by ResurrectionRemix.
the class SimpleMonthView method updateMonthYearLabel.
private void updateMonthYearLabel() {
final String format = DateFormat.getBestDateTimePattern(mLocale, MONTH_YEAR_FORMAT);
final SimpleDateFormat formatter = new SimpleDateFormat(format, mLocale);
formatter.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
mMonthYearLabel = formatter.format(mCalendar.getTime());
}
use of android.icu.text.SimpleDateFormat in project android_frameworks_base by crdroidandroid.
the class DatePickerCalendarDelegate method onLocaleChanged.
@Override
protected void onLocaleChanged(Locale locale) {
final TextView headerYear = mHeaderYear;
if (headerYear == null) {
// again later after everything has been set up.
return;
}
// Update the date formatter.
final String datePattern = DateFormat.getBestDateTimePattern(locale, "EMMMd");
mMonthDayFormat = new SimpleDateFormat(datePattern, locale);
mMonthDayFormat.setContext(DisplayContext.CAPITALIZATION_FOR_STANDALONE);
mYearFormat = new SimpleDateFormat("y", locale);
// Clear out the lazily-initialized accessibility event formatter.
mAccessibilityEventFormat = null;
// Update the header text.
onCurrentDateChanged(false);
}
Aggregations