Decimal format uses BigDecimal .ROUND_HALF_EVEN and this cannot be changed.
If you need an alternate rounding strategy then you need to use BigDecimal to do your formatting.
double d = 123.45;
BigDecimal bd = new BigDecimal(d);
bd.setScale(1, BigDecimal.ROUND_HALF_UP);
String formatted = bd.toString();
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment