public static Object convertNumberToWrapper(Number num,Class<?> wrapper){
  if (wrapper.equals(String.class)) {
    return num.toString();
  }
 else   if (wrapper.equals(Boolean.class)) {
    return Boolean.valueOf(num.intValue() == 1);
  }
 else   if (wrapper.equals(Double.class)) {
    return Double.valueOf(num.doubleValue());
  }
 else   if (wrapper.equals(Long.class)) {
    return Long.valueOf(num.longValue());
  }
 else   if (wrapper.equals(Float.class)) {
    return Float.valueOf(num.floatValue());
  }
 else   if (wrapper.equals(Integer.class)) {
    return Integer.valueOf(num.intValue());
  }
 else   if (wrapper.equals(Short.class)) {
    return Short.valueOf(num.shortValue());
  }
 else   if (wrapper.equals(Byte.class)) {
    return Byte.valueOf(num.byteValue());
  }
  return null;
}

public static Object convertNumberToWrapper ( Number num , Class < ? > wrapper ) { if ( wrapper . equals ( String . class ) ) { return num . toString ( ) ; } else if ( wrapper . equals ( Boolean . class ) ) { return Boolean . valueOf ( num . intValue ( ) == 1 ) ; } else if ( wrapper . equals ( Double . class ) ) { return Double . valueOf ( num . doubleValue ( ) ) ; } else if ( wrapper . equals ( Long . class ) ) { return Long . valueOf ( num . longValue ( ) ) ; } else if ( wrapper . equals ( Float . class ) ) { return Float . valueOf ( num . floatValue ( ) ) ; } else if ( wrapper . equals ( Integer . class ) ) { return Integer . valueOf ( num . intValue ( ) ) ; } else if ( wrapper . equals ( Short . class ) ) { return Short . valueOf ( num . shortValue ( ) ) ; } else if ( wrapper . equals ( Byte . class ) ) { return Byte . valueOf ( num . byteValue ( ) ) ; } return null ; }
convert number to primitive wrapper like boolean or float
