Format the number with specified template, pattern, language and locale
@param number
@param pattern
@param locale
@return the formatted String
@see DecimalFormatSymbols
435718
public static String format(ITemplate template, Number number, String pattern, Locale locale) {
        if (null == number) {
            throw new NullPointerException();
        }
        if (null == locale) {
            locale = I18N.locale(template);
        }
        
        NumberFormat nf;
        if (null == pattern) nf = NumberFormat.getNumberInstance(locale);
        else {
            DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale);
            nf = new DecimalFormat(pattern, symbols);
        }
        
        return nf.format(number);
    }
600111
private static SimpleDateFormat buildDateFormat(final String pattern) {

    SimpleDateFormat simpleDateFormat = simpleDateFormatCache.get();
    if (simpleDateFormat == null) {
      simpleDateFormat = new SimpleDateFormat();
      simpleDateFormatCache.set(simpleDateFormat);
    }
    simpleDateFormat.applyPattern(pattern);
    return simpleDateFormat;
  }
975322
protected function getNumberFormat($locale)
    {
        if (!isset($this->numberFormats[$locale])) {
            $this->numberFormats[$locale] = $this->numberFormatRepository->get($locale);
        }

        return $this->numberFormats[$locale];
    }
503246
public static String formatNumber(int num) {
        DecimalFormat format = new DecimalFormat();
        format.setDecimalSeparatorAlwaysShown(false);
        return format.format(num);
    }
1310556
public void setNumberFormat(final NumberFormat FORMAT) {
        if (null == numberFormat) {
            _numberFormat = null == FORMAT ? NumberFormat.getInstance(getLocale()) : FORMAT;
            fireTileEvent(RESIZE_EVENT);
        } else {
            numberFormat.set(FORMAT);
        }
    }
1190831
public static String format(ITemplate template, Object o, String pattern, Locale locale, String timezone) {
        if (null == o) return "";
        if (o instanceof Date) return format(template, (Date) o, pattern, locale, timezone);
        if (o instanceof Number) return format(template, (Number) o, pattern, locale);
        if (null == locale) {
            locale = I18N.locale(template);
        }
        RythmEngine engine = null == template ? RythmEngine.get() : template.__engine();
        if (null == engine) return o.toString();
        for(IFormatter fmt: engine.extensionManager().formatters()) {
            String s = fmt.format(o, pattern, locale, timezone);
            if (null != s) {
                return s;
            }
        }
        return o.toString();
    }
969905
private String format(double n) {
        NumberFormat nf = NumberFormat.getNumberInstance(Locale.ENGLISH);
        nf.setMaximumFractionDigits(1);
        nf.setGroupingUsed(false);
        return nf.format(n);
    }
131676
private static void decimal(CLDR.Locale locale, String[] numbers, DecimalFormatOptions opts) {
    for (String num : numbers) {
      BigDecimal n = new BigDecimal(num);
      StringBuilder buf = new StringBuilder("  ");
      NumberFormatter fmt = CLDR.get().getNumberFormatter(locale);
      fmt.formatDecimal(n, buf, opts);
      System.out.println(buf.toString());
    }
  }
415909
private NumberFormat parseFormatter(Context context, Arguments args)
    {
        final String format = args.get(FORMAT_PARAM_NAME);
        final Locale locale = context.get(LOCALE);
        if (format != null)
        {
            return new DecimalFormat(format, DecimalFormatSymbols.getInstance(locale));
        }

        final Mode mode = Mode.loadFromContext(args, this.defaultMode);
        if (Mode.INTEGER.equals(mode))
        {
            return NumberFormat.getIntegerInstance(locale);
        }
        if (Mode.CURRENCY.equals(mode))
        {
            return NumberFormat.getCurrencyInstance(locale);
        }
        if (Mode.PERCENT.equals(mode))
        {
            return NumberFormat.getPercentInstance(locale);
        }
        return NumberFormat.getInstance(locale);
    }
225888
public CellFormatResult format(final String formatPattern, final Date value, final Locale locale) {
        return format(new DateCell(value, formatPattern), locale);
    }
663874
public static String format(final String pattern, final Locale locale, final Object... arguments) {
		MessageFormat format = new MessageFormat(pattern, locale);
		return format.format(arguments);
	}
456835
public void formatDecimal(BigDecimal n, StringBuilder destination, DecimalFormatOptions options) {
    DigitBuffer dbuf = new DigitBuffer();
    DecimalFormatStyle style = options.style();
    boolean grouping = orDefault(options.grouping(), false);
    boolean currency = false;
    NumberFormatMode formatMode = orDefault(options.formatMode(), NumberFormatMode.DEFAULT);
    
    switch (style) {
      case DECIMAL:
      {
        NumberFormatContext ctx = new NumberFormatContext(options, NumberFormatMode.DEFAULT);
        NumberPattern pattern = select(n, decimalStandard);
        ctx.set(pattern);
        BigDecimal q = ctx.adjust(n);

        DigitBuffer number = new DigitBuffer();
        NumberFormattingUtils.format(q, number, params, currency, grouping,
            ctx.minIntDigits(),
            pattern.format.primaryGroupingSize(),
            pattern.format.secondaryGroupingSize());
        format(pattern, number, dbuf, null, null);
        dbuf.appendTo(destination);
        break;
      }

      case LONG:
      case SHORT:
      {
        NumberFormatContext ctx = new NumberFormatContext(options, NumberFormatMode.SIGNIFICANT);
        int nDigits = integerDigits(n);
        int nDivisor = getDivisor_DECIMAL_LONG(nDigits);

        // Q1 is the number divided by the divisor (if any).
        BigDecimal q1 = n;
        if (nDivisor > 0) {
          q1 = n.movePointLeft(nDivisor).stripTrailingZeros();
        }
        int q1Digits = integerDigits(q1);

        // Select an initial pattern using the OTHER plural category.
        NumberPattern pattern;
        if (style == DecimalFormatStyle.LONG) {
          pattern = select(n, getPattern_DECIMAL_LONG(nDigits, PluralCategory.OTHER));
        } else {
          pattern = select(n, getPattern_DECIMAL_SHORT(nDigits, PluralCategory.OTHER));
        }
        
        // Q2 is the number adjusted using the pattern and options.
        ctx.setCompact(pattern, q1Digits, nDivisor);
        BigDecimal q2 = ctx.adjust(q1);
        int q2Digits = integerDigits(q2);

        // Number rounded up, we need to select a new divisor and pattern.
        if (q2Digits > q1Digits) {
          // Bump the number of digits by 1 to select the next divisor/pattern.
          nDigits++;
          int divisor = getDivisor_DECIMAL_LONG(nDigits);
          if (style == DecimalFormatStyle.LONG) {
            pattern = select(n, getPattern_DECIMAL_LONG(nDigits, PluralCategory.OTHER));
          } else {
            pattern = select(n, getPattern_DECIMAL_SHORT(nDigits, PluralCategory.OTHER));
          }
          
          // If divisor changed, we need to divide and adjust again. 
          // Otherwise we just use Q2 as-is.
          if (divisor > nDivisor) {
            q1 = n.movePointLeft(divisor).stripTrailingZeros();
            ctx.setCompact(pattern, integerDigits(q1), divisor);
            q2 = ctx.adjust(q1);
          }
        }

        // Compute the plural category.
        NumberOperands operands = new NumberOperands(q2.toPlainString());
        PluralCategory category = PLURAL_RULES.evalCardinal(bundleId.language(), operands);

        // Select the final pluralized pattern.
        if (style == DecimalFormatStyle.LONG) {
          pattern = select(n, getPattern_DECIMAL_LONG(nDigits, category));
        } else {
          pattern = select(n, getPattern_DECIMAL_SHORT(nDigits, category));
        }
        
        // Format the number into the buffer.
        DigitBuffer number = new DigitBuffer();
        NumberFormattingUtils.format(q2, number, params, false, grouping, 
            pattern.format.minimumIntegerDigits, 
            decimalStandard[0].format.primaryGroupingSize, 
            decimalStandard[0].format.secondaryGroupingSize);
        
        // Format the entire pattern and append to destination.
        format(pattern, number, dbuf, null, null);
        dbuf.appendTo(destination);
        break;
      }
      
      case PERCENT:
      case PERCENT_SCALED:
      case PERMILLE:
      case PERMILLE_SCALED:
      {
        // In default modes, scale the number. Otherwise assume it is already scaled
        // appropriately.
        if (style == PERCENT || style == PERMILLE) {
          n = n.movePointRight(style == PERCENT ? 2 : 3);
        }
        String symbol = (style == PERCENT) || (style == PERCENT_SCALED) ? params.percent : params.perMille;
        NumberPattern pattern = select(n, percentStandard);
        DigitBuffer number = new DigitBuffer();
        setup(params, pattern, n, number, options, null, formatMode, grouping, -1, -1, -1);
        format(pattern, number, dbuf, null, symbol);
        dbuf.appendTo(destination);
        break;
      }
    }
  }
292411
private NumberFormat createFormatter(Locale loc) throws JspException {
        NumberFormat formatter = null;

        if ((type == null) || NUMBER.equalsIgnoreCase(type)) {
            formatter = NumberFormat.getNumberInstance(loc);
        } else if (CURRENCY.equalsIgnoreCase(type)) {
            formatter = NumberFormat.getCurrencyInstance(loc);
        } else if (PERCENT.equalsIgnoreCase(type)) {
            formatter = NumberFormat.getPercentInstance(loc);
        } else {
            throw new JspException(
                    Resources.getMessage("FORMAT_NUMBER_INVALID_TYPE", type));
        }

        return formatter;
    }
56561
public function formatByIntlLocalizedDecimal(
        $locale = null,
        Currencies $currencies = null,
        $style = NumberFormatter::CURRENCY
    ) {
        $numberFormatter = new NumberFormatter($locale ?: static::getLocale(), $style);
        $formatter = new IntlLocalizedDecimalFormatter($numberFormatter, $currencies ?: static::getCurrencies());

        return $this->formatByFormatter($formatter);
    }
1066372
protected static NumberPattern parse(String pattern) {
    return NUMBER_PATTERN_CACHE.computeIfAbsent(pattern, s -> new NumberPatternParser().parse(s));
  }
13024
public static String formatCurrency(Object data, String currencyCode, Locale locale) {
        return formatCurrency(null, data, currencyCode, locale);
    }
891586
public String formatAsString(final String formatPattern, final String value, final Locale locale) {
        return format(formatPattern, value, locale).getText();
    }