The following function rounds any number to a specified number of decimal places. Of course, there are other ways of doing this in Java (using the BigInteger / BigDecimal classes for example), but if you don't need control over the rounding mode, this is an easy way to solve the problem:
public double redondear( double numero, int decimales ) { return Math.round(numero*Math.pow(10,decimales))/Math.pow(10,decimales); }