views:

1109

answers:

3

Hello all,

I'm new to Java and trying to take a BigDecimal (for example 99999999.99) and convert it to a string but without the decimal place and trailing numbers. Also, I don't want commas in the number and rounding is not needed.

I've tried:

Math.Truncate(number)

but BigDecimal is not supported.

Any ideas?

Thanks very much.

+3  A: 

Try number.toBigInteger().toString()

David Zaslavsky
Perfect, thanks.
Zero Cool
+2  A: 

Use this.

BigDecimal truncated= number.setScale(0,BigDecimal.ROUND_DOWN);
S.Lott
+1  A: 

BigDecimal without fractions is BigInteger. Why don't you just use BigInteger?

ZZ Coder