Java Fraction Format formatNumber(float num, String format)

Here you can find the source of formatNumber(float num, String format)

Description

format the number

License

Open Source License

Parameter

Parameter Description
num the float number value
format "##,###.##","##.##"

Return

true if it is ascii;false otherwise

Declaration

public static String formatNumber(float num, String format) 

Method Source Code

//package com.java2s;

import java.text.DecimalFormat;

public class Main {
    /**// w w  w  .j a va2  s  .  c om
     * format the number
     * 
     * 
     * @param num the float number value
     * @param format "##,###.##","##.##"
     * @return <code>true</code> if it is ascii;<code>false</code> otherwise
     */
    public static String formatNumber(float num, String format) {
        DecimalFormat df = new DecimalFormat(format);
        return df.format(num);
    }
}

Related

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