Thursday, November 6, 2008

Value rounding in java

use the following method to value round in java


double round = 134.23445;
java.text.NumberFormat nf = new java.text.DecimalFormat("0.00");
System.out.println(nf.format(round));
if you need to round a value to three positions
new java.text.DecimalFormat("0.000");

No comments:

Post a Comment