Search in sources :

Example 1 with NumberFormat

use of android.icu.text.NumberFormat in project android_packages_apps_Settings by omnirom.

the class FileSizeFormatter method formatRoundedBytesResult.

private static String formatRoundedBytesResult(@NonNull Context context, @NonNull RoundedBytesResult input) {
    final Locale locale = localeFromContext(context);
    final NumberFormat numberFormatter = getNumberFormatter(locale, input.fractionDigits);
    return formatMeasureShort(locale, numberFormatter, input.value, input.units);
}
Also used : Locale(java.util.Locale) NumberFormat(android.icu.text.NumberFormat)

Example 2 with NumberFormat

use of android.icu.text.NumberFormat in project android_packages_apps_Settings by crdroidandroid.

the class FileSizeFormatter method formatRoundedBytesResult.

private static String formatRoundedBytesResult(@NonNull Context context, @NonNull RoundedBytesResult input) {
    final Locale locale = localeFromContext(context);
    final NumberFormat numberFormatter = getNumberFormatter(locale, input.fractionDigits);
    return formatMeasureShort(locale, numberFormatter, input.value, input.units);
}
Also used : Locale(java.util.Locale) NumberFormat(android.icu.text.NumberFormat)

Example 3 with NumberFormat

use of android.icu.text.NumberFormat in project android_packages_apps_Settings by SudaMod.

the class FileSizeFormatter method formatRoundedBytesResult.

private static String formatRoundedBytesResult(@NonNull Context context, @NonNull RoundedBytesResult input) {
    final Locale locale = localeFromContext(context);
    final NumberFormat numberFormatter = getNumberFormatter(locale, input.fractionDigits);
    return formatMeasureShort(locale, numberFormatter, input.value, input.units);
}
Also used : Locale(java.util.Locale) NumberFormat(android.icu.text.NumberFormat)

Example 4 with NumberFormat

use of android.icu.text.NumberFormat in project android_packages_apps_Settings by DirtyUnicorns.

the class FileSizeFormatter method getNumberFormatter.

private static NumberFormat getNumberFormatter(Locale locale, int fractionDigits) {
    final NumberFormat numberFormatter = NumberFormat.getInstance(locale);
    numberFormatter.setMinimumFractionDigits(fractionDigits);
    numberFormatter.setMaximumFractionDigits(fractionDigits);
    numberFormatter.setGroupingUsed(false);
    if (numberFormatter instanceof DecimalFormat) {
        // We do this only for DecimalFormat, since in the general NumberFormat case, calling
        // setRoundingMode may throw an exception.
        numberFormatter.setRoundingMode(BigDecimal.ROUND_HALF_UP);
    }
    return numberFormatter;
}
Also used : DecimalFormat(android.icu.text.DecimalFormat) NumberFormat(android.icu.text.NumberFormat)

Example 5 with NumberFormat

use of android.icu.text.NumberFormat in project android_packages_apps_Settings by DirtyUnicorns.

the class FileSizeFormatter method formatRoundedBytesResult.

private static String formatRoundedBytesResult(@NonNull Context context, @NonNull RoundedBytesResult input) {
    final Locale locale = localeFromContext(context);
    final NumberFormat numberFormatter = getNumberFormatter(locale, input.fractionDigits);
    return formatMeasureShort(locale, numberFormatter, input.value, input.units);
}
Also used : Locale(java.util.Locale) NumberFormat(android.icu.text.NumberFormat)

Aggregations

NumberFormat (android.icu.text.NumberFormat)105 Test (org.junit.Test)84 ULocale (android.icu.util.ULocale)39 RuleBasedNumberFormat (android.icu.text.RuleBasedNumberFormat)35 DecimalFormat (android.icu.text.DecimalFormat)27 Locale (java.util.Locale)24 ParseException (java.text.ParseException)20 ParsePosition (java.text.ParsePosition)13 DecimalFormatSymbols (android.icu.text.DecimalFormatSymbols)12 CompactDecimalFormat (android.icu.text.CompactDecimalFormat)11 FieldPosition (java.text.FieldPosition)9 IOException (java.io.IOException)7 DateFormat (android.icu.text.DateFormat)5 Calendar (android.icu.util.Calendar)5 Date (java.util.Date)5 BigDecimal (android.icu.math.BigDecimal)4 DisplayContext (android.icu.text.DisplayContext)4 MeasureFormat (android.icu.text.MeasureFormat)4 SimpleDateFormat (android.icu.text.SimpleDateFormat)4 PluralFormat (android.icu.text.PluralFormat)3