Java Float Number Create toFloat(Object val)

Here you can find the source of toFloat(Object val)

Description

to Float

License

Apache License

Declaration

public static Float toFloat(Object val) 

Method Source Code

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

public class Main {

    public static Float toFloat(Object val) {
        return toDouble(val).floatValue();
    }//  ww  w. ja v  a  2 s . c o m

    public static Double toDouble(Object val) {
        if (val == null) {
            return 0D;
        }
        try {
            return Double.valueOf(trim(val.toString()));
        } catch (Exception e) {
            return 0D;
        }
    }

    public static String trim(String str) {
        return (null == str) ? null : str.trim();
    }
}

Related

  1. toFloat(Object obj)
  2. toFloat(Object obj)
  3. toFloat(Object obj, String pattern)
  4. toFloat(Object rawColor)
  5. toFloat(Object v)
  6. toFloat(Object val)
  7. toFloat(Object value)
  8. toFloat(Object value)
  9. toFloat(Object value)