Java Program to convert String containing decimal values into BigDecimal :
Sometime, we try to convert the String containing the decimal values into the Long. But since, int and long are Integer type so they can't have the decimal values to Long.valueOf(StringValue) gives the error.
The correct approach is to convert the string decimal into the BigDecimal or Double and use them as decimal values.
Example :
String double_as_string = "23.23";
BigDecimal price = new BigDecimal(double_as_string);
No comments:
Post a Comment