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;
}
}
判空工具方法
最新推荐文章于 2024-07-13 02:46:22 发布