Java Utililty Methods Float Number Create

List of utility methods to do Float Number Create

Description

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

Method

floattoFloat(String str)
to Float
return toFloat(str, 0.0f);
floattoFloat(String str, float defaultValue)

Convert a String to a float, returning a default value if the conversion fails.

if (str == null) {
    return defaultValue;
try {
    return Float.parseFloat(str);
} catch (NumberFormatException nfe) {
    return defaultValue;
floattoFloat(String str, float defaultValue)
Convert the string to int.
float value = defaultValue;
try {
    value = Float.parseFloat(str);
} catch (NumberFormatException e) {
    value = defaultValue;
return value;
floattoFloat(String string)
to Float
if (isEmpty(string)) {
    return 0.0f;
try {
    return Float.parseFloat(string);
} catch (NumberFormatException ex) {
    return 0.0f;
FloattoFloat(String text)
Converts a string of text to a float value.
try {
    return Float.parseFloat(text);
} catch (NumberFormatException e) {
    return null;
FloattoFloat(String text)
Converts a string to a Float.
if (text == null) {
    return null;
return new Float(text);
FloattoFloat(String value)
to Float
if (null == value) {
    return null;
value = value.trim();
if ("null".equals(value)) {
    return null;
return Float.parseFloat(value);
...
floattoFloat(String value)
Gets the float value of the input string value.
try {
    value = value.replaceAll("[\\s+ \\$]", "");
    if (value != null) {
        return Float.parseFloat(value);
} catch (Exception ex) {
return 0;
...
floattoFloat(String value, float _default)
to Float
if (value == null || value.length() == 0)
    return _default;
return Float.valueOf(value);
FloattoFloat(String value, Float defaultValue)
to Float
if (isEmpty(value))
    return defaultValue;
try {
    return Float.parseFloat(value);
} catch (Exception e) {
    return defaultValue;