public class DaoUtil{ /** * 将null转换为空字符串 * @param value * @return */ public static String nullToString(Object value){ return value==null?"":value.toString().trim(); } /** * 将null或空字符串转换为html的空格字符 (可适用于列表显示表格线) * @param value * @return */ public static String nullToNBSP(Object value){ return (value==null || "".equals(value.toString().trim()))?" ":value.toString().trim(); } /** * 将null转换为字符串_nbsp * @param e * @return */ public static String toNBSP(Object e) { String s = "_nbsp"; if (e != null && !"".equals(e.toString().trim())) { s = e.toString().trim(); } return s; } /** * 将null或空字符串转换为String类型0 * @param value * @return */ public static String nullToNumber(Object value){ return (value==null || "".equals(value.toString().trim()))?"0":value.toString().trim(); } /** * 将null或空字符串转换为int类型0 * @param value * @return */ public static int nullToNumber2(Object value){ return (value==null || "".equals(value.toString().trim()))?0:Integer.parseInt(value.toString().trim()); } /** * 将null或空字符串转换为double类型0 * @param value * @return */ public static double nullToNumber3(Object value){ return (value==null || "".equals(value.toString().trim()))?0:Double.parseDouble(value.toString().trim()); }}