Search in sources :

Example 56 with LocaleData

use of libcore.icu.LocaleData in project robolectric by robolectric.

the class ShadowLocaleData method get.

@Implementation
public static LocaleData get(Locale locale) {
    LocaleData localeData = (LocaleData) Shadow.newInstanceOf(REAL_CLASS_NAME);
    if (locale == null) {
        locale = Locale.getDefault();
    }
    setEnUsLocaleData(localeData);
    return localeData;
}
Also used : LocaleData(libcore.icu.LocaleData) Implementation(org.robolectric.annotation.Implementation)

Example 57 with LocaleData

use of libcore.icu.LocaleData in project robolectric by robolectric.

the class ShadowLocaleDataTest method shouldSupportLocaleEn_US.

@Test
public void shouldSupportLocaleEn_US() throws Exception {
    LocaleData localeData = LocaleData.get(Locale.US);
    assertThat(localeData.amPm).isEqualTo(new String[] { "AM", "PM" });
    assertThat(localeData.eras).isEqualTo(new String[] { "BC", "AD" });
    assertThat(localeData.firstDayOfWeek).isEqualTo(1);
    assertThat(localeData.minimalDaysInFirstWeek).isEqualTo(1);
    assertThat(localeData.longMonthNames).isEqualTo(new String[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" });
    assertThat(localeData.shortMonthNames).isEqualTo(new String[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" });
    assertThat(localeData.longStandAloneMonthNames).isEqualTo(localeData.longMonthNames);
    assertThat(localeData.shortStandAloneMonthNames).isEqualTo(localeData.shortMonthNames);
    assertThat(localeData.longWeekdayNames).isEqualTo(new String[] { "", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" });
    assertThat(localeData.shortWeekdayNames).isEqualTo(new String[] { "", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" });
    assertThat(localeData.longStandAloneWeekdayNames).isEqualTo(localeData.longWeekdayNames);
    assertThat(localeData.shortStandAloneWeekdayNames).isEqualTo(localeData.shortWeekdayNames);
    assertThat(localeData.fullTimeFormat).isEqualTo("h:mm:ss a zzzz");
    assertThat(localeData.longTimeFormat).isEqualTo("h:mm:ss a z");
    assertThat(localeData.mediumTimeFormat).isEqualTo("h:mm:ss a");
    assertThat(localeData.shortTimeFormat).isEqualTo("h:mm a");
    assertThat(localeData.fullDateFormat).isEqualTo("EEEE, MMMM d, y");
    assertThat(localeData.longDateFormat).isEqualTo("MMMM d, y");
    assertThat(localeData.mediumDateFormat).isEqualTo("MMM d, y");
    assertThat(localeData.shortDateFormat).isEqualTo("M/d/yy");
    assertThat(localeData.zeroDigit).isEqualTo('0');
    assertThat(localeData.decimalSeparator).isEqualTo('.');
    assertThat(localeData.groupingSeparator).isEqualTo(',');
    assertThat(localeData.patternSeparator).isEqualTo(';');
    assertThat(localeData.perMill).isEqualTo('‰');
    assertThat(localeData.monetarySeparator).isEqualTo('.');
    assertThat(localeData.exponentSeparator).isEqualTo("E");
    assertThat(localeData.infinity).isEqualTo("∞");
    assertThat(localeData.NaN).isEqualTo("NaN");
    assertThat(localeData.currencySymbol).isEqualTo("$");
    assertThat(localeData.internationalCurrencySymbol).isEqualTo("USD");
    assertThat(localeData.numberPattern).isEqualTo("#,##0.###");
    assertThat(localeData.integerPattern).isEqualTo("#,##0");
    assertThat(localeData.currencyPattern).isEqualTo("¤#,##0.00;(¤#,##0.00)");
    assertThat(localeData.percentPattern).isEqualTo("#,##0%");
}
Also used : LocaleData(libcore.icu.LocaleData) Test(org.junit.Test)

Example 58 with LocaleData

use of libcore.icu.LocaleData in project robolectric by robolectric.

the class ShadowLocaleDataTest method shouldSupportLocaleEn_US_since_jelly_bean_mr1.

@Test
@Config(minSdk = JELLY_BEAN_MR1)
public void shouldSupportLocaleEn_US_since_jelly_bean_mr1() throws Exception {
    LocaleData localeData = LocaleData.get(Locale.US);
    assertThat(localeData.tinyMonthNames).isEqualTo(new String[] { "J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D" });
    assertThat(localeData.tinyStandAloneMonthNames).isEqualTo(localeData.tinyMonthNames);
    assertThat(localeData.tinyWeekdayNames).isEqualTo(new String[] { "", "S", "M", "T", "W", "T", "F", "S" });
    assertThat(localeData.tinyStandAloneWeekdayNames).isEqualTo(localeData.tinyWeekdayNames);
    assertThat(localeData.yesterday).isEqualTo("Yesterday");
    assertThat(localeData.today).isEqualTo("Today");
    assertThat(localeData.tomorrow).isEqualTo("Tomorrow");
}
Also used : LocaleData(libcore.icu.LocaleData) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 59 with LocaleData

use of libcore.icu.LocaleData in project robolectric by robolectric.

the class ShadowLocaleDataTest method shouldSupportLocaleEn_US_since_lollipop.

@Test
@Config(minSdk = LOLLIPOP)
public void shouldSupportLocaleEn_US_since_lollipop() throws Exception {
    LocaleData localeData = LocaleData.get(Locale.US);
    assertThat(localeData.minusSign).isEqualTo("-");
}
Also used : LocaleData(libcore.icu.LocaleData) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 60 with LocaleData

use of libcore.icu.LocaleData in project android_frameworks_base by ResurrectionRemix.

the class TimePickerSpinnerDelegate method getAmPmStrings.

public static String[] getAmPmStrings(Context context) {
    String[] result = new String[2];
    LocaleData d = LocaleData.get(context.getResources().getConfiguration().locale);
    result[0] = d.amPm[0].length() > 4 ? d.narrowAm : d.amPm[0];
    result[1] = d.amPm[1].length() > 4 ? d.narrowPm : d.amPm[1];
    return result;
}
Also used : LocaleData(libcore.icu.LocaleData)

Aggregations

LocaleData (libcore.icu.LocaleData)70 SpannableStringBuilder (android.text.SpannableStringBuilder)12 Context (android.content.Context)6 Spanned (android.text.Spanned)6 SpannedString (android.text.SpannedString)6 CharacterStyle (android.text.style.CharacterStyle)6 RelativeSizeSpan (android.text.style.RelativeSizeSpan)6 SimpleDateFormat (java.text.SimpleDateFormat)6 Locale (java.util.Locale)6 Test (org.junit.Test)6 Config (org.robolectric.annotation.Config)4 Date (java.util.Date)3 Resources (android.content.res.Resources)1 Implementation (org.robolectric.annotation.Implementation)1