//转换成Integer类型
public static Integer TryParseToInteger(Object obj, String name) throws ApiSrvException {
Integer result = null;
if (obj != null&&!obj.equals("")) {
try {
result = Integer.valueOf(obj.toString());
}catch (Exception ex){
throw new ApiSrvException(name + "类型转换失败", ExCode.MSG_RESOLVE_ERR, new IllegalArgumentException());
}
}
return result;
}

//转换成BigDecimal类型
public static BigDecimal TryParseToBigDecimal(Object obj, String name) throws ApiSrvException {
BigDecimal result = null;
if (obj != null&&!obj.equals("")) {
try {
result = new BigDecimal(obj.toString());
} catch (Exception ex){
throw new ApiSrvException(name + "类型转换失败", ExCode.MSG_RESOLVE_ERR, new IllegalArgumentException());
}
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-10-22
  • 2021-11-18
  • 2021-11-30
  • 2022-01-11
猜你喜欢
  • 2022-12-23
  • 2021-09-14
  • 2022-02-17
  • 2022-12-23
相关资源
相似解决方案