code: public static Object castNumberType(Object object, Class clazz) {
  
          if (Number.class.isAssignableFrom(clazz)) {
              //            AtomicInteger, AtomicLong, BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, Short
              if (Double.class.isAssignableFrom(clazz)) {
                  return ((Number) object).doubleValue();
              } else if (Long.class.isAssignableFrom(clazz)) {
                  return ((Number) object).longValue();
  
              } else if (Float.class.isAssignableFrom(clazz)) {
                  return ((Number) object).floatValue();
  
              } else if (Integer.class.isAssignableFrom(clazz)) {
                  return ((Number) object).intValue();
  
              } else if (Short.class.isAssignableFrom(clazz)) {
                  return ((Number) object).shortValue();
  
              } else if (Byte.class.isAssignableFrom(clazz)) {
                  return ((Number) object).byteValue();
  
              } else if (BigInteger.class.isAssignableFrom(clazz)) {
                  return BigInteger.valueOf(((Number) object).longValue());
  
              } else if (BigDecimal.class.isAssignableFrom(clazz)) {
                  return BigDecimal.valueOf(((Number) object).longValue());
  
              } else if (AtomicLong.class.isAssignableFrom(clazz)) {
                  return new AtomicLong(((Number) object).longValue());
  
              } else if (AtomicInteger.class.isAssignableFrom(clazz)) {
                  return new AtomicInteger(((Number) object).intValue());
              }
          }
          throw new ClassCastException("it is not a Number Type" + object.getClass() + "|" + clazz);
      }
docs: Cast number type.
  
  @param object the object
  @param clazz  the clazz
  @return object