数字转字符串<br>
调用{@link Number#toString()}，并去除尾小数点儿后多余的0

@param number A Number
@param defaultValue 如果number参数为{@code null}，返回此默认值
@return A String.
@since 3.0.9
425080
public static String toStr(Number number, String defaultValue) {
		return (null == number) ? defaultValue : toStr(number);
	}
736921
public int getProperty(String key, int defaultValue) {
        String value = getProperty(key, String.class);
        return StringUtils.isEmpty(value) ? defaultValue : Integer.parseInt(value);
    }
783410
public String optString(String key, String defaultValue) {
    Object o = opt(key);
    return o != null ? o.toString() : defaultValue;
  }
695483
public static Character toChar(Object value, Character defaultValue) {
		return convert(Character.class, value, defaultValue);
	}
990837
public static char toCharValue(Object o, char defaultValue) {
	if (o instanceof Character) return ((Character) o).charValue();
	else if (o instanceof Boolean) return (char) ((((Boolean) o).booleanValue()) ? 1 : 0);
	else if (o instanceof Double) return (char) (((Double) o).doubleValue());
	else if (o instanceof Number) return (char) (((Number) o).doubleValue());
	else if (o instanceof String) {
	    String str = o.toString();
	    if (str.length() > 0) return str.charAt(0);
	    return defaultValue;

	}
	else if (o instanceof ObjectWrap) {
	    return toCharValue(((ObjectWrap) o).getEmbededObject(toCharacter(defaultValue)), defaultValue);
	}
	else if (o == null) return toCharValue("", defaultValue);
	return defaultValue;
    }
774266
public static Object stringToValue(String string) {
		if (string.equals("")) {
			return string;
		}
		if (string.equalsIgnoreCase("true")) {
			return Boolean.TRUE;
		}
		if (string.equalsIgnoreCase("false")) {
			return Boolean.FALSE;
		}
		if (string.equalsIgnoreCase("null")) {
			return JSONObject.NULL;
		}

		/*
		 * If it might be a number, try converting it. If a number cannot be
		 * produced, then the value will just be a string.
		 */

		char initial = string.charAt(0);
		if ((initial >= '0' && initial <= '9') || initial == '-') {
			try {
				if (string.indexOf('.') > -1 || string.indexOf('e') > -1
						|| string.indexOf('E') > -1
						|| "-0".equals(string)) {
					Double d = Double.valueOf(string);
					if (!d.isInfinite() && !d.isNaN()) {
						return d;
					}
				} else {
					Long myLong = new Long(string);
					if (string.equals(myLong.toString())) {
						if (myLong.longValue() == myLong.intValue()) {
							return Integer.valueOf(myLong.intValue());
						}
						return myLong;
					}
				}
			} catch (Exception ignore) {}
		}
		return string;
	}
873698
public static Long toLongObject(@Nullable String str, Long defaultValue) {
		if (StringUtils.isEmpty(str)) {
			return defaultValue;
		}
		try {
			return Long.valueOf(str);
		} catch (final NumberFormatException nfe) {
			return defaultValue;
		}
	}
935475
public static String toStr(Number number) {
		if (null == number) {
			throw new NullPointerException("Number is null !");
		}

		if (false == ObjectUtil.isValidIfNumber(number)) {
			throw new IllegalArgumentException("Number is non-finite!");
		}

		// 去掉小数点儿后多余的0
		String string = number.toString();
		if (string.indexOf('.') > 0 && string.indexOf('e') < 0 && string.indexOf('E') < 0) {
			while (string.endsWith("0")) {
				string = string.substring(0, string.length() - 1);
			}
			if (string.endsWith(".")) {
				string = string.substring(0, string.length() - 1);
			}
		}
		return string;
	}
543239
public int toInt(int defaultValue) {
		try {
			return Integer.parseInt(sb.toString());
		} catch (java.lang.NumberFormatException e) {
			e.printStackTrace();
		}
		return defaultValue;
	}
750116
public int getInt(String key, int defaultValue) {
    	String value = get(key);
    	if(value == null) return defaultValue;
    	try {
    		return Integer.parseInt(value);
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException(key + " parameter should be a number");
        }
    }
1099709
public static int toIntValue(Object o, int defaultValue) {

	if (o instanceof Number) return ((Number) o).intValue();
	else if (o instanceof Boolean) return ((Boolean) o).booleanValue() ? 1 : 0;
	else if (o instanceof CharSequence) return toIntValue(o.toString().trim(), defaultValue);
	// else if(o instanceof Clob) return toIntValue(toString(o));
	else if (o instanceof Character) return (int) (((Character) o).charValue());
	else if (o instanceof Castable) {
	    return (int) ((Castable) o).castToDoubleValue(defaultValue);

	}
	else if (o instanceof Date) return (int) new DateTimeImpl((Date) o).castToDoubleValue();
	else if (o instanceof ObjectWrap) return toIntValue(((ObjectWrap) o).getEmbededObject(Integer.valueOf(defaultValue)), defaultValue);

	return defaultValue;
    }
651961
public static int intVal(String val, int defaultValue) {
        try {
            return NumberUtils.createNumber(val).intValue();
        } catch (Exception e) {
            log.warn("intVal(String, int) throw {}, return defaultValue = {}", e, defaultValue);
            return defaultValue;
        }
    }
880788
public static String getString(HttpServletRequest request, String parameterName, String defaultValue) {
		String value = request.getParameter(parameterName);
		if (value == null || value.length() == 0) {
			return defaultValue;
		}
		else {
			return value;
		}
		// return StringUtils.isEmpty(value) ? defaultValue : value;
	}
1160355
public static String numberToString(Number number) throws JsonException {
        if (number == null) {
            throw new JsonException("Number must be non-null");
        }

        double doubleValue = number.doubleValue();

        // the original returns "-0" instead of "-0.0" for negative zero
        if (number.equals(NEGATIVE_ZERO)) {
            return "-0";
        }

        long longValue = number.longValue();
        if (doubleValue == (double) longValue) {
            return Long.toString(longValue);
        }

        return number.toString();
    }
766264
public static String getStringValue(Object newValue, String defaultValue) {
        if (newValue == null)
            return defaultValue;

        return (String) newValue;
    }
264646
public static int parseInt(String num, int defaultInt) {
        if (num == null) {
            return defaultInt;
        } else {
            try {
                return Integer.parseInt(num);
            } catch (Exception e) {
                return defaultInt;
            }
        }
    }
1219301
public int getValue(String attributeName, int defaultValue) {
        A attribute = getAt(attributeName);
        Object attributeValue = (attribute == null) ? null : attribute.getValue();
        return (attributeValue == null) ? defaultValue : Integer.parseInt(attributeValue.toString());
    }