Here you can find the source of roundTwoDecimals(double d)
Parameter | Description |
---|---|
d | The decimal number. |
public static final Double roundTwoDecimals(double d)
//package com.java2s; import java.text.DecimalFormat; public class Main { /**/*from www . j a va2 s.c om*/ * This method rounds up a decimal number up to N decimals. i.e.. 4,5687 -> * 4,56 * * @param d The decimal number. * * @return The rounded number. */ public static final Double roundTwoDecimals(double d) { DecimalFormat twoDForm = new DecimalFormat("#.##"); return Double.valueOf(twoDForm.format(d)); } }