Search code examples
javasqlbigdecimal

In Database, One Column has value as "0.000000000000". How to print the "0.000000000000" as a whole?


In the Database, 1 column has a value stored as "0.000000000000". I need to compare it with UI field which has exactly same value.

I tried to get the value with Big Decimal and tried to convert it into String but it always coverts it into '0E-12' or '0.0'. How Can I compare it with UI (which is in String format)?


Solution

  • Have you tried

    BigDecimal bd = new BigDecimal("0.000000000000");
    System.out.println(bd.toPlainString().equals("0.000000000000"));
    

    output

    true