Jingqi Xu
Jingqi Xu

Reputation: 289

Java BigDecimal.toPlainString() performance

Java BigDecimal.toPlainString() becomes hot spot of my app. Is there a faster way to get plain string of BigDecimal?

Upvotes: 4

Views: 2065

Answers (1)

Pritam Banerjee
Pritam Banerjee

Reputation: 18958

toString() method can be an option.

But just ran a test on it , toPlainString() was the clear winner.

From Oracle Docs:

String toPlainString() Returns a string representation of this BigDecimal without an exponent field.

String toString() Returns the string representation of this BigDecimal, using scientific notation if an exponent is needed.

Upvotes: 1

Related Questions