java - How to get Integer of BigDecimal without separator -


i got following bigdecimal money-object: bigdecimal 49.99 , need integer 4999, ask getting rid of separator.

i bigdecimal string , remove separator , parse integer, not think pretty.

bigdecimal bigprice = moneyprice.getvalue(); integer price = bigprice.intvalue(); 

using responses 49.

try code:

bigdecimal db = new bigdecimal("49.99"); // multiply 10^scale ( in case 2) db = db.multiply(new bigdecimal(10).pow( db.scale())); system.out.println(db.intvalue()); 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -