对Double类型数据进行截取

2025-04-07 03:39:17

1、对Double类型数据进行截取(转换方法1)public static void main(String[] args) { Double ss = 18000.2; String test = ss+""; String NewNum = test.substring(0,test.length()-4)+"."+test.substring(test.length()-4,test.length()-2); Double fromString = new Double(NewNum); System.out.println(fromString);}

对Double类型数据进行截取

2、对Double类型数据进行截取(转换方法2)public static void main(String[] args) { Dou芟鲠阻缒ble ss = 18000.2; String test = ss+""; String NewNum = test.substring(0,test.length()-4)+"."+test.substring(test.length()-4,test.length()-2); Double doubleString = Double.parseDouble(NewNum); System.out.println(doubleString);}

对Double类型数据进行截取

3、对Double类型数据进行截取(转换方法3)public static void main(String[] args) { Double ss = 18000.2; String test = ss+""; String NewNum = test.substring(0,test.length()-4)+"."+test.substring(test.length()-4,test.length()-2); Double doubleString = Double.valueOf(NewNum); System.out.println(doubleString);}

对Double类型数据进行截取
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢