How can I use NumberFormat to format a double value for a given Locale (default locale is sufficient) and for a given number of decima
converts a double value to a double value with any number of digits after decimal. I have created this method in a Utility class to access it through out the project.
public static double convertToDecimal(double doubleValue, int numOfDecimals) {
BigDecimal bd = new BigDecimal(doubleValue);
bd = bd.setScale(numOfDecimals, BigDecimal.ROUND_HALF_UP);
return bd.doubleValue();
}