if ((flags & TFormattableFlags.GROUPING_SEPARATOR) != 0) { char separator = new DecimalFormatSymbols(locale).getGroupingSeparator(); int size = ((DecimalFormat) NumberFormat.getNumberInstance(locale)).getGroupingSize(); int offset = str.length() % size; if (offset == 0) {
/** * Return the grouping size. Grouping size is the number of digits between grouping separators in the integer portion of a number. For example, in the number "123,456.78", the grouping size is 3. */ public int getGroupingSize(){ return format.getGroupingSize(); } /**
/** * Returns the grouping size. Grouping size is the number of digits between grouping * separators in the integer portion of a number. For example, in the number * "123,456.78", the grouping size is 3. * * @see #setGroupingSize * @see NumberFormat#isGroupingUsed * @see DecimalFormatSymbols#getGroupingSeparator * @stable ICU 2.0 */ public int getGroupingSize() { return ((java.text.DecimalFormat)numberFormat).getGroupingSize(); }
/** * Returns the grouping size. Grouping size is the number of digits between grouping * separators in the integer portion of a number. For example, in the number * "123,456.78", the grouping size is 3. * * @see #setGroupingSize * @see NumberFormat#isGroupingUsed * @see DecimalFormatSymbols#getGroupingSeparator * @stable ICU 2.0 */ public int getGroupingSize() { return ((java.text.DecimalFormat)numberFormat).getGroupingSize(); }
/** * Returns a help string that indicates the recommended number input format for the current locale. This will be the * locale-specific format. The input funcitons all tolerate plain math numbers (without groupings), though the * locale-specific fraction separator is required. * * @param nFractional Indicate the number of fractional digits wanted. 0 means you want an integer. * @return A string representing the recommended number input for the locale. * @see I#preferredCurrencyFormat() */ public static String preferredNumberFormat(int nFractional) { LanguageSetting s = languageProvider.vend(); NumberFormat fmt = NumberFormat.getInstance(s.locale); StringBuffer rv = new StringBuffer(); if (fmt instanceof DecimalFormat) { DecimalFormat cfmt = ((DecimalFormat) fmt); int groupSize = cfmt.getGroupingSize(); DecimalFormatSymbols symbols = cfmt.getDecimalFormatSymbols(); rv.append("#"); rv.append(symbols.getGroupingSeparator()); for (int i = 0; i < groupSize; i++) rv.append("#"); if (nFractional > 0) { rv.append(symbols.getDecimalSeparator()); for (int i = 0; i < nFractional; i++) rv.append("#"); } } return rv.toString(); }
void transform_f() { StringBuilder pattern = new StringBuilder(); if (formatToken.isFlagSet(FormatToken.FLAG_COMMA)) { pattern.append(','); int groupingSize = decimalFormat.getGroupingSize(); if (groupingSize > 1) { char[] sharps = new char[groupingSize - 1]; Arrays.fill(sharps, '#'); pattern.append(sharps); } } pattern.append(0); if (formatToken.getPrecision() > 0) { pattern.append('.'); char[] zeros = new char[formatToken.getPrecision()]; Arrays.fill(zeros, '0'); pattern.append(zeros); } decimalFormat.applyPattern(pattern.toString()); result.append(decimalFormat.format(argument)); // if the flag is sharp and decimal seperator is always given // out. if (formatToken.isFlagSet(FormatToken.FLAG_SHARP) && 0 == formatToken.getPrecision()) { char dot = decimalFormat.getDecimalFormatSymbols() .getDecimalSeparator(); result.append(dot); } }
DecimalFormat cfmt = ((DecimalFormat) fmt); int fractional = cfmt.getMaximumFractionDigits(); int groupSize = cfmt.getGroupingSize(); DecimalFormatSymbols symbols = cfmt.getDecimalFormatSymbols(); rv.append("#");
String fmt = format.toPattern(); boolean groupingUsed = format.isGroupingUsed(); int groupingSize = format.getGroupingSize();
DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(locale); NumberFormat format = NumberFormat.getCurrencyInstance(locale); int size = (format instanceof DecimalFormat ? ((DecimalFormat) format).getGroupingSize() : 3); size = size <= 0 ? 3 : size; protoStyle = new MoneyAmountStyle(
@Override protected NumberSymbols createObject(Locale locale, NumberType numberType, Object... params) throws Exception { DecimalFormat df = null; switch (numberType) { case INTEGER: df = (DecimalFormat) DecimalFormat.getIntegerInstance(locale); break; case PERCENT: df = (DecimalFormat) DecimalFormat.getPercentInstance(locale); break; case DECIMAL: default: df = (DecimalFormat) DecimalFormat.getNumberInstance(locale); break; } DecimalFormatSymbols dfs = df.getDecimalFormatSymbols(); return new NumberSymbols(numberType, df.getNegativePrefix(), df.getNegativeSuffix(), df.getPositivePrefix(), df.getPositiveSuffix(), df.getGroupingSize(), dfs.getGroupingSeparator(), dfs.getDecimalSeparator()); } };
grouping += ",groupSize:" + format.getGroupingSize(); } else {
grouping += ",groupSize:" + format.getGroupingSize(); } else {
grouping += ",groupSize:" + format.getGroupingSize(); } else {
grouping += ",groupSize:" + format.getGroupingSize(); } else {
grouping += ",groupSize:" + format.getGroupingSize(); } else {
grouping += ",groupSize:" + format.getGroupingSize(); } else {