Java Number Format Pattern getFormattedNumber(String input)

Here you can find the source of getFormattedNumber(String input)

Description

get Formatted Number

License

Open Source License

Declaration

public static String getFormattedNumber(String input) 

Method Source Code


//package com.java2s;
import java.text.DecimalFormat;

public class Main {
    private static DecimalFormat df = null;

    public static String getFormattedNumber(String input) {
        if (df == null) {
            return input;
        }//  w ww .j a  v  a2 s. c o m

        try {
            return df.format(Double.parseDouble(input));
        } catch (NumberFormatException nfe) {
            return input;
        }
    }
}

Related

  1. getFormatedInt(int maxValue)
  2. getFormatedPrice(BigDecimal price)
  3. getFormattedInteger(int n)
  4. getFormattedNumber(int number)
  5. getFormattedNumber(NumberFormat numberFormat, String fieldValue, Class valueClass)
  6. getFormattedQuantity(String qty, int len, String pad)
  7. getFormattedString4Digits(String number, String pattern)
  8. getFormatter()
  9. getFormatter()