[英]String format in java?
Input String: 115.0000 输入字符串:115.0000
Output String should be like: 115.00 输出字符串应类似于:115.00
i used this code: 我用这个代码:
String.format("%.2f","115.0000");
i got IllegalArgumentException
. 我收到了IllegalArgumentException
。 What can i do now? 我现在能做什么?
You're submitting a string, but telling it to expect a floating point value. 您正在提交一个字符串,但是告诉它期望一个浮点值。 Remove the quotes around the number (second parameter). 删除数字(第二个参数)周围的引号。
String.format("%.2f", Double.parseDouble("115.0000"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.