Java Float Number Create toFloat(String value, Float defaultValue)

Here you can find the source of toFloat(String value, Float defaultValue)

Description

to Float

License

Open Source License

Declaration

public static Float toFloat(String value, Float defaultValue) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static Float toFloat(String value, Float defaultValue) {
        if (isEmpty(value))
            return defaultValue;
        try {/*  w  w  w  .  j  a  v  a 2 s  . c  o m*/
            return Float.parseFloat(value);
        } catch (Exception e) {
            return defaultValue;
        }
    }

    public static boolean isEmpty(String str) {
        if (str == null)
            return true;

        if ("".equals(str.trim()))
            return true;

        return false;
    }
}

Related

  1. toFloat(String text)
  2. toFloat(String text)
  3. toFloat(String value)
  4. toFloat(String value)
  5. toFloat(String value, float _default)
  6. toFloat(String value, float defaultValue)
  7. toFloat(T value)
  8. toFloatA(byte[] data)
  9. toFloatObject(Object o)