The java.math.BigDecimal.toPlainString() method is used to represent the current BigDecimal by which this method is called into String form without an exponent field. If the values are with a positive scale, the number of digits to the right of the decimal point is used to indicate scale. For values with a zero or negative scale, the resulting string is generated as if the value were converted to a numerically equal value with zero scale and as if all the trailing zeros of the zero scale value were present in the result.
Note: If the result of this method is passed to the string constructor, only the numerical value of this BigDecimal will be recovered, the representation of the new BigDecimal may have a different scale. In particular, this method behaves analogously to the toString method.
public String toPlainString()
Parameter: This method do not accepts any parameter.
Return value: This method returns the String representation of this BigDecimal number without an exponent field.
Below programs illustrates the use of toPlainString() method in java
Example 1: Example to convert BigDecimal into plain String without exponent notation
Example 2: Example to convert BigDecimal into plain String with exponent notation
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.