public static Number convert ( Number value , Class < ? > type ) { if ( int . class . equals ( type ) || Integer . class . equals ( type ) ) value = value . intValue ( ) ; else if ( long . class . equals ( type ) || Long . class . equals ( type ) ) value = value . longValue ( ) ; else if ( short . class . equals ( type ) || Short . class . equals ( type ) ) value = value . shortValue ( ) ; else if ( byte . class . equals ( type ) || Byte . class . equals ( type ) ) value = value . byteValue ( ) ; else if ( double . class . equals ( type ) || Double . class . equals ( type ) ) value = value . doubleValue ( ) ; else if ( float . class . equals ( type ) || Float . class . equals ( type ) ) value = value . floatValue ( ) ; return value ; }
Converts a Number value to a Integer Long Short Byte Double or Float . If unable to convert the original value is returned .