Java Float Number Create toFloat(final String value)

Here you can find the source of toFloat(final String value)

Description

To float.

License

Apache License

Parameter

Parameter Description
value the value

Return

the float

Declaration

public static float toFloat(final String value) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*w w w  .ja  v  a 2 s  .  c  o m*/
     * To float.
     *
     * @param value the value
     * @return the float
     */
    public static float toFloat(final String value) {
        if (value == null) {
            return 0.0F;
        }

        String szTemp = "";

        for (int i = 0; i < value.length(); i++)
            if (value.charAt(i) != ',') {
                szTemp = szTemp + value.charAt(i);
            }

        try {
            final float f = Float.parseFloat(szTemp);

            return f;
        } catch (final NumberFormatException e) {
            final float f1 = 0.0F;

            return f1;
        }
    }
}

Related

  1. toFloat(final Integer value)
  2. toFloat(final Object o, final String pattern)
  3. toFloat(final Object obj)
  4. toFloat(final Object valueRep)
  5. toFloat(final String value)
  6. toFloat(final String value)
  7. toFloat(Float num, float defaultValue)
  8. toFloat(int colorComponent)
  9. toFloat(int hbits)