Java Fraction Format formatNumber(int fractionDigits, double value)

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

Description

format Number

License

Open Source License

Declaration

public static String formatNumber(int fractionDigits, double value) 

Method Source Code


//package com.java2s;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.List;

public class Main {
    static List<NumberFormat> nfs = new ArrayList<NumberFormat>();

    public static String formatNumber(int fractionDigits, double value) {
        if (fractionDigits >= 0 && fractionDigits <= 10) {
            return nfs.get(fractionDigits).format(value);
        }// w w  w  .j  a  v a  2  s.c om

        throw new RuntimeException("Only supports fraction digits between 0 to 10");
    }
}

Related

  1. formatNumber(double value)
  2. formatNumber(double value, double epsilon)
  3. formatNumber(final double number)
  4. formatNumber(Float d, int scalar)
  5. formatNumber(float num, String format)
  6. formatNumber(String Format, double Num)
  7. formatNumber(String format, double number)
  8. formatNumber(String number, int maxFractionalDigits)
  9. formatNumberAttribute(double v)