You can use the setScale() method to control the rounding of a decimal value as shown in the following example:
double value = 123.456789;
BigDecimal bd = new BigDecimal(value).setScale(2, BigDecimal.ROUND_HALF_UP);
Standard rounding provided by BigDecimal and DecimalFormat rounds to the nearest 0 or 1. If you instead want to round to 0, 1 or 0.5 then you need to do a little work
For example to round up to 4 decimal places to the nearest 0, 1, or .5 you could use the following code.
BigDecimal bd = new BigDecimal((d * 2.0) + 0.0005)
bd = new BigDecimal(bd.doubleValue()/2.0)
String rounded = bd.toString();
Decimal format uses BigDecimal.ROUND_HALF_EVEN and prior to 1.6 this cannot be changed.
In 1.6 a setRoundingMethod() was added to allow the rounding strategy to be changed.
DecimalFormat df = NumberFormat.getNumberInstance();
String formatted = df.format(12.345);
If you need an alternate rounding strategy prior to 1.6 then you need to use BigDecimal to do your formatting.
double d = 123.45;
BigDecimal bd = new BigDecimal(d);
String formatted = bd.toString();