public class NumberParseUtil {
private static final Logger logger = LoggerFactory
.getLogger(NumberParseUtil.class);
public static int parseInt(String str) throws Exception {
if (str == null) {
return 0;
} else {
try {
return Integer.parseInt(str);
} catch (Exception e) {
logger.error("int类型转换错误", e);
throw new Exception();
}
}
}
public static float parseFloat(String str) throws Exception {
if (str == null) {
return 0;
} else {
try {
return Float.parseFloat(str);
} catch (Exception e) {
logger.error("float类型转换错误", e);
throw new Exception();
}
}
}
}
private static final Logger logger = LoggerFactory
.getLogger(NumberParseUtil.class);
public static int parseInt(String str) throws Exception {
if (str == null) {
return 0;
} else {
try {
return Integer.parseInt(str);
} catch (Exception e) {
logger.error("int类型转换错误", e);
throw new Exception();
}
}
}
public static float parseFloat(String str) throws Exception {
if (str == null) {
return 0;
} else {
try {
return Float.parseFloat(str);
} catch (Exception e) {
logger.error("float类型转换错误", e);
throw new Exception();
}
}
}
}