我在货币对象中获得价值,但我只想要双重格式。如何将货币格式转换为java中的两倍
String amt = txn.getAmount();
System.out.println("--amt--"+amt);//output:1010
double value = Double.parseDouble(amt);
System.out.println("---value---"+value);//output:1010.0
String ammount=NumberFormat.getCurrencyInstance().format(value);
System.out.println("--ammount--"+ammount);//output:Rs.1,010.00
在这里,我想向Rs.1,010.00
1010.00
在我的代码的任何错误呢?
的可能的复制[?如何显示浮点数据在Java 2位小数输出(http://stackoverflow.com/questions/2538787/how-to-display -an-output-of-float-data-with-2-decimal-places-in-java) –
你为什么要'getAmount'返回一个字符串? –
@ cricket_007:不重复请仔细观察, – Durga