Here you can find the source of getBigDecimal(final String str, final int scale)
Parameter | Description |
---|---|
input | String : str int : scale |
public static BigDecimal getBigDecimal(final String str, final int scale)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.math.RoundingMode; public class Main { /**// w w w . ja v a 2s. co m * This method will return a BigDecimal for a given input string and * specified scale. * * @param input * String : str int : scale * @return the BigDecimal */ public static BigDecimal getBigDecimal(final String str, final int scale) { BigDecimal returnValue; try { returnValue = new BigDecimal(str).setScale(scale, RoundingMode.HALF_UP); } catch (Exception exception) { returnValue = new BigDecimal("0.00"); } return returnValue; } }