Java Fraction Format FormatFolat(Float num)

Here you can find the source of FormatFolat(Float num)

Description

Format Folat

License

Open Source License

Declaration

public static Float FormatFolat(Float num) 

Method Source Code


//package com.java2s;
import java.text.DecimalFormat;

public class Main {

    public static Float FormatFolat(Float num) {
        if (num == null) {
            return null;
        }/*from ww w.j av  a 2 s.  c  o m*/

        int p_num = num.toString().indexOf(".");
        if (((num.toString().length()) - p_num - 1) > 5) {
            if (Integer.parseInt(num.toString().substring(p_num + 6, p_num + 7)) >= 5) {
                num = num + new Float(0.000001);
            }
        }
        DecimalFormat df = new DecimalFormat("####.00000");
        return new Float(df.format(num));
    }
}

Related

  1. formatFloat(float number, int numberOfAfterDot)
  2. formatFloat(Float someFloat)
  3. FormatFloat(float value, int point)
  4. formatFloat(String format, double f)
  5. formatFloatToStr(Float str)
  6. formatGetal(float getal)
  7. formatIndexValuePairs(List indicies, List values, String valueSeparator, String rangeSeparator)
  8. formatInt(double value)
  9. formatIntoCurr(double num, int digits)