Java Double Number Format format(double number, int nums)

Here you can find the source of format(double number, int nums)

Description

format

License

Open Source License

Declaration

public static String format(double number, int nums) 

Method Source Code

//package com.java2s;

public class Main {

    public static String format(double number, int nums) {
        //      return new BigDecimal(number).setScale(nums, BigDecimal.ROUND_HALF_UP).doubleValue();
        //      return Double.valueOf(new DecimalFormat("#.00").format(number));
        return String.format("%." + nums + "f", number);
    }/*  ww  w.ja  v a 2  s.c o  m*/
}

Related

  1. format(double d, int decimals)
  2. format(Double decimal)
  3. format(double num, int n)
  4. format(double number)
  5. format(Double number)
  6. format(double number, int precision)
  7. format(double size, String type)
  8. format(double val, int n, int w)
  9. format(double value, int decimalPlaces)