public static float toPrimitiveFloat(Object o, String pattern) {
        if (o == null) {
            return 0;
        } else if (o instanceof Number) {
            return ((Number) o).floatValue();
        } else if (o instanceof String) {
            return toPrimitiveFloat((String) o);
        } else if (o instanceof java.util.Date) {
            if (pattern != null) {
                return Float.parseFloat(new SimpleDateFormat(pattern).format(o));
            }
            return ((java.util.Date) o).getTime();
        } else {
            return toPrimitiveFloat(o.toString());
        }
    }
public static float toPrimitiveFloat ( Object o , String pattern ) { if ( o == null ) { return 0 ; } else if ( o instanceof Number ) { return ( ( Number ) o ) . floatValue ( ) ; } else if ( o instanceof String ) { return toPrimitiveFloat ( ( String ) o ) ; } else if ( o instanceof java . util . Date ) { if ( pattern != null ) { return Float . parseFloat ( new SimpleDateFormat ( pattern ) . format ( o ) ) ; } return ( ( java . util . Date ) o ) . getTime ( ) ; } else { return toPrimitiveFloat ( o . toString ( ) ) ; } }
@param o
@param pattern
@return float