Here's a quick and dirty example to do it explicitly:
class Rounder{
public static void main(String[] args){
double d = 18.4567;
double rounded = (int)(100*d+0.5)/100.0;
System.out.println("rounded number = "+rounded);
}
}
If you meant "truncate" instead of round, leave off the 0.5.
"java.util.DecimalFormat"... What was I thinking! It's java.text.DecimalFormat:import java.text.*;
...
DecimalFormat format = new DecimalFormat("#.00");
StringBuffer formatted = format.format(Math.PI, new StringBuffer(), new FieldPosition(0));
System.out.println(formatted); // prints out 3.14