Java Utililty Methods Number Format

List of utility methods to do Number Format

Description

The list of methods to do Number Format are organized into topic(s).

Method

StringnumberFormat(double value, String format)
number Format
DecimalFormat objDecimalFormat = new DecimalFormat(format);
return objDecimalFormat.format(value);
NumberFormatnumberFormat(int fractionDigits, Locale locale)
number Format
NumberFormat nf = NumberFormat.getInstance(locale);
nf.setMinimumFractionDigits(fractionDigits);
nf.setMaximumFractionDigits(fractionDigits);
return nf;
StringnumberFormat(int i)
number Format
return NF.format(i);
StringnumberFormat(int num)
number Format
NumberFormat nf = NumberFormat.getInstance();
return nf.format(num);
StringnumberFormat(Number number, String... pattern)
number Format
return isNull((Object[]) pattern) ? FORMAT.format(number) : FORMAT.format(pattern[0]);
StringnumberFormat(String pattern, BigDecimal number)
number Format
String numberStr = null;
if (number == null) {
    return "";
try {
    if (pattern == null || pattern.equals("")) {
        numberStr = new DecimalFormat("#0.00##").format(number.doubleValue());
    } else {
...
StringnumberFormat(String pattern, double value)
Returns an text with the value formatted.
DecimalFormat myFormatter = new DecimalFormat(pattern);
return myFormatter.format(value);
intnumberFormate(double num)
number Formate
DecimalFormat df = new DecimalFormat("#####0");
String formatNum = df.format(num);
return Integer.parseInt(formatNum);
StringnumberFormatHelper(String string, double d)
number Format Helper
if (d == (int) d) {
    return String.format(string + " %d", (int) d);
} else {
    return String.format(string + " %s", new DecimalFormat("#.##").format(d));
DecimalFormatnumberFormatter(String pattern, int maxDigits)
number Formatter
DecimalFormat f = new DecimalFormat(pattern );
f.setMaximumFractionDigits(maxDigits);
return f;