Java Object to Float objectToFloat(Object obj)

Here you can find the source of objectToFloat(Object obj)

Description

object To Float

License

Apache License

Declaration

public static float objectToFloat(Object obj) 

Method Source Code

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

public class Main {

    public static float objectToFloat(Object obj) {
        return objectToFloat(obj, 0f);
    }//from  w ww .  j av a 2 s.  c  om

    public static float objectToFloat(Object obj, float added) {
        float result = 0;
        try {
            result = Float.parseFloat(obj.toString());
        } catch (Exception e) {
            result = added;
        }
        return result;
    }
}

Related

  1. castToFloat(final double v)
  2. castToFloat(final String uid)
  3. objectToFloat(Object o)
  4. objectToInt(Object o)
  5. objectToInt(Object o)
  6. objectToInt(Object obj)
  7. objectToInt(Object Obj)