Rounding Double values using DecimalFormat
DecimalFormat dform = new DecimalFormat("#.##");
Double dtotal = new Double(12.23454647);
System.out.println("dtotal: "+dtotal);
dtotal = Double.valueOf(dform.format(dtotal));
System.out.println("dtotal: "+dtotal);
output:
dtotal: 12.23454647
dtotal: 12.23
No comments:
Post a Comment