Here you can find the source of roundTwoDecimals(Double d)
Parameter | Description |
---|---|
d | a parameter |
public static Double roundTwoDecimals(Double d)
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; public class Main { /**// w w w .j a va 2s.c o m * Round up to two decimals * * @param d * @return */ public static Double roundTwoDecimals(Double d) { DecimalFormat twoDForm = new DecimalFormat("###.##"); DecimalFormatSymbols dfs = new DecimalFormatSymbols(); dfs.setDecimalSeparator('.'); twoDForm.setDecimalFormatSymbols(dfs); return Double.valueOf(twoDForm.format(d)); } }