现在有一个String ,String str = "2584aba31474e19074c1231818221609";想把他变成10进制,放到数据库中去,数据库的字段是 NUMBER(38),求教,怎么在java种转过来提交到数据库。
Connection conn= null;
ConnPool pool = new ConnPool();
PreparedStatement pst=null;
ResultSet rs=null;conn=pool.createConnection();
……
Connection conn= null;
ConnPool pool = new ConnPool();
PreparedStatement pst=null;
ResultSet rs=null;conn=pool.createConnection();
……
Integer.valueOf("FFFF",16).toString()
String str = "2584aba31474e19074c1231818221609";
你把它转成int试试。
String str = "2584aba31474e19074c1231818221609";
你把它转成int试试。
没环境
是不是转为10进制后数据值太大了?那就用long类型.
String str = "2584aba31474e19074c1231818221609";
long l = Long.parseLong(str, 16);
直接就报错了……错误为:
java.lang.NumberFormatException: For input string: "2584aba31474e19074c1231818221609"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Long.parseLong(Long.java:406)小弟在线等啊………………
如果没有现成的java method,可以写个循环啊,遍历整个串,按进制的转换规则计算出来.