Java Utililty Methods Fraction Format

List of utility methods to do Fraction Format

Description

The list of methods to do Fraction Format are organized into topic(s).

Method

StringformatFloat(float f, String format)
format Float
DecimalFormat df = new DecimalFormat(format);
return df.format(f);
floatformatFloat(float num)
format Float
float q = 0f;
try {
    DecimalFormat df = new DecimalFormat("#.###");
    q = Float.parseFloat(df.format(num).replace(",", "."));
} catch (Exception e) {
    e.printStackTrace();
return q;
...
StringformatFloat(float number)
format Float
return floatFormat.format(number);
floatformatFloat(float number, int numberOfAfterDot)
format Float
String format = ".";
for (int i = 0; i < numberOfAfterDot; i++) {
    format += "0";
DecimalFormat decimalFormat = new DecimalFormat(format);
String tmp = decimalFormat.format(number);
return Float.parseFloat(tmp);
StringformatFloat(Float someFloat)
Formats a float as a string with a default number of significant digits depending on the argument's value.
return formatDouble(someFloat.doubleValue());
StringFormatFloat(float value, int point)
Format Float
NumberFormat numFormat = NumberFormat.getNumberInstance();
numFormat.setMaximumFractionDigits(point);
String str = numFormat.format(value);
return str;
StringformatFloat(String format, double f)
format Float
StringBuffer formatString = new StringBuffer(format);
java.text.DecimalFormat df = new java.text.DecimalFormat(formatString.toString());
return df.format(f);
StringformatFloatToStr(Float str)
format Float To Str
return formatFloatToStr(str, null);
FloatFormatFolat(Float num)
Format Folat
if (num == null) {
    return null;
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));
StringformatGetal(float getal)
format Getal
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
dfs.setGroupingSeparator('.');
dfs.setDecimalSeparator(',');
DecimalFormat decimalFormat = new DecimalFormat("0.##");
decimalFormat.setDecimalFormatSymbols(dfs);
return decimalFormat.format(getal);