Java Utililty Methods Float to String

List of utility methods to do Float to String

Description

The list of methods to do Float to String are organized into topic(s).

Method

StringFloatToString(float value)
Float To String
Float f = new Float(value);
NumberFormat fmt = NumberFormat.getNumberInstance();
String s = fmt.format(f.doubleValue());
return s;
StringfloatToString(float value)
convert float to String with two fractional digits
if (Float.isNaN(value)) {
    return " --- ";
return String.format("%.2f", value);
StringfloatToString(float value, int precision)
Converts a float to a string.
String str = String.valueOf(value);
int dot = str.indexOf('.');
if (precision > 0) {
    precision++;
if (dot > 0 && str.length() > dot + precision) {
    str = str.substring(0, dot + precision);
return str;
StringfloatToString(float value, String format)
Converts a float to a string.
return doubleToString(value, format);
String[]floatToString(float[] values)
float To String
if (values == null) {
    return null;
String[] results = new String[values.length];
for (int i = 0; i < values.length; i++) {
    results[i] = String.valueOf(values[i]);
return results;
...
StringfloatToString0(float value)
float To String
if (Float.isNaN(value)) {
    value = 0f;
return String.format("%.2f", value);