Here you can find the source of roundDecimal(Double value)
public static Double roundDecimal(Double value)
//package com.java2s; //License from project: Open Source License public class Main { public static final int DEFAULT_DECIMALS = 3; public static Double roundDecimal(Double value) { return roundDecimal(value, DEFAULT_DECIMALS); }/*from w ww.j a v a2s. c o m*/ public static Double roundDecimal(Double value, int decimals) { double coeficient = Math.pow(10, decimals); return Math.round(value * coeficient) / coeficient; } }