版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/XUEER88888888888888/article/details/86559836
package com.zlhj.util;
import java.math.BigDecimal;
public class ConvertionUtil {
public static boolean getBoolean(Object o) {
boolean value = false;
try {
String str = "" + o;
if (str.equalsIgnoreCase("yes") || str.equalsIgnoreCase("true") || str.equalsIgnoreCase("ok")) {
value = true;
}
} catch (Exception arg2) {
;
}
return value;
}
public static int getInteger(Object o) {
int value = 0;
try {
value = Integer.parseInt("" + o);
} catch (Exception arg2) {
;
}
return value;
}
public static String getString(Object o) {
String value = "";
try {
value = "" + o;
} catch (Exception arg2) {
;
}
return value;
}
public static String getSimpleStringWithNull(Object obj) {
return obj != null ? ("" + obj).trim() : "";
}
//int类型
public static int getSimpleIntegerWithNull(Object obj) {
int ret = 0;
try {
ret = Integer.parseInt(getSimpleStringWithNull(obj));
} catch (Exception arg2) {
;
}
return ret;
}
//符点
public static double getSimpleDoubleWithNull(Object obj) {
double ret = 0.0D;
try {
ret = Double.parseDouble(getSimpleStringWithNull(obj));
} catch (Exception arg3) {
;
}
return ret;
}
}