Java Number Format Pattern toFormattedNumber(Object value)

Here you can find the source of toFormattedNumber(Object value)

Description

to Formatted Number

License

Open Source License

Declaration

public static String toFormattedNumber(Object value) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.DecimalFormat;

public class Main {
    static DecimalFormat DEFAULT_DECIMAL_FORMATTER = new DecimalFormat("#.####");

    public static String toFormattedNumber(Object value) {
        if (value == null) {
            return "";
        }/*from w  w w  . j  a  v  a2s. c om*/
        if (value instanceof Double || value instanceof Float) {
            return DEFAULT_DECIMAL_FORMATTER.format(value);
        }
        return value.toString();
    }
}

Related

  1. stringFormat(BigDecimal value)
  2. stringToReais(String unformatted, boolean comSimbolo)
  3. strToFormatedNumber(String str)
  4. toAccountantFormat(String str, int scale)
  5. toDecimalFormat(BigDecimal value)
  6. toNumber(String numString, String numFormatPattern)
  7. toNumberFormat(String input)
  8. toString(int[] a, String separator, NumberFormat formatter)
  9. toStringFormatted(byte[] bytes)