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

Stringformat(double value, String formatString)
format
return new DecimalFormat(formatString).format(value);
doubleformat(double x, int max, int min)
format
NumberFormat nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(max);
nf.setMinimumFractionDigits(min);
try {
    Number number = nf.parse(nf.format(x));
    x = number.doubleValue();
} catch (Exception e) {
    e.printStackTrace();
...
Stringformat(final double d)
Formats a number.
final StringBuffer s = new StringBuffer();
return FORMAT_DOUBLE.format(d, s, new java.text.FieldPosition(0)).toString();
Stringformat(final double number)
format
return DEFAULT_FORMAT.format(number);
Stringformat(final double value)
format
return DF.format(value);
Stringformat(final double value, final int decimalPlaces)
Formats a double value with a given number of decimal places.
final DecimalFormat formatter = getDecimalFormat(decimalPlaces);
return formatter.format(value);
Stringformat(final NumberFormat fmt, final double val)
Format the given double value using given formater Note: this method is not thread safe (synchronization must be performed by callers)
_fmtBuffer.setLength(0);
return format(fmt, _fmtBuffer, val).toString();
Stringformat(float f)
format
numberFormat.setMaximumFractionDigits(2);
return numberFormat.format(f);
Stringformat(Float f)
format
return df.format(f);
Stringformat(float num)
format
df.setMaximumFractionDigits(3);
df.setMinimumFractionDigits(0);
return df.format(num);