Java Number Format formatNumber(Double val, int numDec, int width)

Here you can find the source of formatNumber(Double val, int numDec, int width)

Description

format Number

License

LGPL

Declaration

public static String formatNumber(Double val, int numDec, int width) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static final String UNKNOWN_VALUE = "-";

    public static String formatNumber(Double val, int numDec, int width) {
        if (val == null) {
            return String.format("%" + width + "s", UNKNOWN_VALUE);
        } else {//from  w w  w  . j av  a2s.c o  m
            return String.format("%" + width + "." + numDec + "f", val);
        }
    }
}

Related

  1. formatNationalNumber(String nationalNumber)
  2. formatNCPDPNumber(String origNumber, int decimalPoints)
  3. formatNumber(double dd)
  4. formatNumber(double dscore)
  5. formatNumber(double number, int decimalPlaces)
  6. formatNumber(double value)
  7. formatNumber(double value)
  8. formatNumber(final long number)
  9. formatNumber(final String number)