Java Number Format formatNumber(double value)

Here you can find the source of formatNumber(double value)

Description

format Number

License

Open Source License

Declaration

public static String formatNumber(double value) 

Method Source Code

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

public class Main {
    public static String formatNumber(double value) {
        if (value < 1000D)
            return String.valueOf(value);
        else if (value < 1000000D)
            return String.valueOf(Math.round(value) / 1000D) + "K";
        else if (value < 1000000000D)
            return String.valueOf(Math.round(value / 1000D) / 1000D) + "M";
        else if (value < 1000000000000D)
            return String.valueOf(Math.round(value / 1000000D) / 1000D) + "B";
        else//w w w . j  a  va2s . c  o  m
            return String.valueOf(Math.round(value / 1000000000D) / 1000D) + "T";
    }
}

Related

  1. formatNCPDPNumber(String origNumber, int decimalPoints)
  2. formatNumber(double dd)
  3. formatNumber(double dscore)
  4. formatNumber(double number, int decimalPlaces)
  5. formatNumber(Double val, int numDec, int width)
  6. formatNumber(double value)
  7. formatNumber(final long number)
  8. formatNumber(final String number)
  9. formatNumber(final StringBuilder buf, final long number)