title: Extracting the integer and fractional part from Bigdecimal in Java
body: <p>I want to extract the integer part and decimal part from the bigdecimal in java.</p>
  
  <p>I am using the following code for that.</p>
  
  <pre><code>    BigDecimal bd = BigDecimal.valueOf(-1.30)
      String textBD = bd.toPlainString();
      System.out.println("length = "+textBD.length());
      int radixLoc = textBD.indexOf('.');
      System.out.println("Fraction "+textBD.substring(0,radixLoc)+"Cents: " + textBD.substring(radixLoc + 1, textBD.length()));
  </code></pre>
  
  <p>I am getting the output as </p>
  
  <p><strong>-1 and 3</strong></p>
  
  <p>But I want the trailing zero also from -1.30</p>
  
  <p>Output should be <strong>-1 and 30</strong></p>