Here you can find the source of formatNumber(Object number, String pattern, Locale locale)
Parameter | Description |
---|---|
number | number |
pattern | pattern |
locale | locale |
public static String formatNumber(Object number, String pattern, Locale locale)
//package com.java2s; //License from project: Open Source License import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.text.NumberFormat; import java.util.*; public class Main { /**// w ww.jav a 2 s .c o m * format number by pattern and locale * * @param number number * @param pattern pattern * @param locale locale * @return String */ public static String formatNumber(Object number, String pattern, Locale locale) { if (number instanceof String) { return (String) number; } DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(locale); NumberFormat parser = new DecimalFormat(pattern, decimalFormatSymbols); return parser.format(number); } }