Thursday, December 17, 2009

Java BigDecimal how to format

Code:

BigDecimal bd = new BigDecimal(1.0);


Result:

>>> alexey: Asd.main bd.toPlainString() = 1
>>> #0.0## -> 1.0


ORrrrr:

Code:

BigDecimal bd = new BigDecimal("1.0");

System.out.println(">>> alexey: Asd.main bd.toPlainString() = " + bd.toPlainString());


Result:

>>> alexey: Asd.main bd.toPlainString() = 1.0


http://java.sun.com/j2se/1.5.0/docs/api/java/text/DecimalFormat.html

No comments: