Java Fraction Format formatDecimal(double number)

Here you can find the source of formatDecimal(double number)

Description

format Decimal

License

Open Source License

Declaration

public static String formatDecimal(double number) 

Method Source Code


//package com.java2s;

import java.text.NumberFormat;

public class Main {

    public static String formatDecimal(double number) {
        NumberFormat format = NumberFormat.getInstance();

        format.setMaximumIntegerDigits(Integer.MAX_VALUE);
        format.setMaximumFractionDigits(2);
        format.setMinimumFractionDigits(2);

        return format.format(number);
    }//from   w w w  . ja v  a  2s  .c  o  m

    public static String formatDecimal(double number, int minFractionDigits, int maxFractionDigits) {
        NumberFormat format = NumberFormat.getInstance();
        format.setMinimumFractionDigits(minFractionDigits);
        format.setMaximumFractionDigits(minFractionDigits);

        return format.format(number);
    }
}

Related

  1. formatCPUUtilization(double d)
  2. formatD(double d)
  3. formatData(double aAmount)
  4. formatDataValue(double value)
  5. formatDecimal(double dtSource, String nbit)
  6. formatDecimal(double numToFormat)
  7. formatDecimal(double value)
  8. formatDecimal(double value, int maxFractionDigits1, int maxFractionDigits2)
  9. formatDecimal(double value, int precision)