Java Utililty Methods String to Float

List of utility methods to do String to Float

Description

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

Method

floatasFloat(final String str, final float def)
Parse string to float, if string can't be parsed to float, then it will return given default value.
try {
    return Float.parseFloat(str);
} catch (final NumberFormatException e) {
    return def;
FloatasFloat(String string)
Converts string to float
return (string == null) ? null : Float.valueOf(string);
FloatasFloat(String v)
as Float
try {
    return (v != null) ? Float.valueOf(v) : null;
} catch (NumberFormatException ex) {
    return null;
floatasFloat(String value)
Converts a String value into a float.
return Float.parseFloat(value);
floatatof(final String str, final float def)
atof
try {
    return Float.parseFloat(str);
} catch (final Exception ex) {
    ex.printStackTrace();
return def;