Java Fraction Format format(double number, String fmt)

Here you can find the source of format(double number, String fmt)

Description

format

License

Open Source License

Declaration

public static String format(double number, String fmt) 

Method Source Code

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

import java.math.BigDecimal;
import java.text.DecimalFormat;

public class Main {
    public static String format(long number, String fmt) {
        return new DecimalFormat(fmt).format(number);
    }//from  w ww  .j a va2  s.c  o m

    public static String format(double number, String fmt) {
        return new DecimalFormat(fmt).format(number);
    }

    public static String format(Object number, String fmt) {

        if (number instanceof String) {
            return new DecimalFormat(fmt).format(new BigDecimal(
                    (String) number));
        } else {
            return new DecimalFormat(fmt).format(number);
        }

    }
}

Related

  1. format(double num, String pattern)
  2. format(double number)
  3. format(double number)
  4. format(double number)
  5. format(double number, int digits)
  6. format(double price)
  7. format(double val)
  8. format(double val)
  9. format(double val)