BigDecimal to string

后端 未结 8 1777
感情败类
感情败类 2020-12-13 08:06

I have a BigDecimal object and i want to convert it to string. The problem is that my value got fraction and i get a huge number (in length) and i only need the original num

8条回答
  •  感动是毒
    2020-12-13 08:39

    By using below method you can convert java.math.BigDecimal to String.

       BigDecimal bigDecimal = new BigDecimal("10.0001");
       String bigDecimalString = String.valueOf(bigDecimal.doubleValue());
       System.out.println("bigDecimal value in String: "+bigDecimalString);
    

    Output:
    bigDecimal value in String: 10.0001

提交回复
热议问题