/** * <p>Convert a <code>String</code> to an <code>int</code>, returning * <code>zero</code> if the conversion fails.</p> * * <p>If the string is <code>null</code>, <code>zero</code> is returned.</p> * * <pre> * NumberUtil.toInt(null) = 0 * NumberUtil.toInt("") = 0 * NumberUtil.toInt("1") = 1 * </pre> * * @param str the string to convert, may be null * @return the int represented by the string, or <code>zero</code> if * conversion fails */ NumberUtil.toInt(String str);
toInt
/** * <p>Convert a <code>String</code> to an <code>int</code>, returning a * default value if the conversion fails.</p> * * <p>If the string is <code>null</code>, the default value is returned.</p> * * <pre> * NumberUtil.toInt(null, 1) = 1 * NumberUtil.toInt("", 1) = 1 * NumberUtil.toInt("1", 0) = 1 * </pre> * * @param str the string to convert, may be null * @param defaultValue the default value * @return the int represented by the string, or the default if conversion fails */ NumberUtil.toInt(String str, int defaultValue);
toLong
/** * <p>Convert a <code>String</code> to a <code>long</code>, returning * <code>zero</code> if the conversion fails.</p> * * <p>If the string is <code>null</code>, <code>zero</code> is returned.</p> * * <pre> * NumberUtil.toLong(null) = 0L * NumberUtil.toLong("") = 0L * NumberUtil.toLong("1") = 1L * </pre> * * @param str the string to convert, may be null * @return the long represented by the string, or <code>0</code> if * conversion fails */ NumberUtil.toLong(String str);
toLong
/** * <p>Convert a <code>String</code> to a <code>long</code>, returning a * default value if the conversion fails.</p> * * <p>If the string is <code>null</code>, the default value is returned.</p> * * <pre> * NumberUtil.toLong(null, 1L) = 1L * NumberUtil.toLong("", 1L) = 1L * NumberUtil.toLong("1", 0L) = 1L * </pre> * * @param str the string to convert, may be null * @param defaultValue the default value * @return the long represented by the string, or the default if conversion fails */ NumberUtil.toLong(String str, long defaultValue);
to62Str
/** * 将 long 转短字符串 为 62 进制 * @param i 数字 * @return 短字符串 */ NumberUtil.to62Str(long i);