好像把"08"这样的字符串当做8进制了,而日期的月份小于10时MM获取到就是两位数0开头,一下代码转的时候报错
public class Test {
public static void main(String[] args) {
Nums.Radix ni = Nums.evalRadix("08");
Integer.valueOf(ni.val,ni.radix);
}
}
public static Radix evalRadix(String str) {
if (str.startsWith("0x"))
return new Radix(str.substring(2), 16);
if (str.startsWith("0") && str.length() > 1)
return new Radix(str.substring(1), 8);
if (str.startsWith("0b"))
return new Radix(str.substring(2), 2);
return new Radix(str, 10);
}
Exception in thread "main" java.lang.NumberFormatException: For input string: "8"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:740)
at Test.main(Test.java:13)