You can round a double using the setScale() method of BigDecimal class. This method is vlaid after Java 1.1. An example of doing this is shown below:

 import java.math.*;

public class divers {
  public static void main(String args[]){
    divers d = new divers();
    d.testRound();
    }

  public void testRound(){
    double r = 3.1537;
    int decimalPlace = 2;
    BigDecimal bd = new BigDecimal(r);
    bd = bd.setScale(decimalPlace,BigDecimal.ROUND_UP);
    r = bd.doubleValue();
    System.out.println(r); // output is 3.15
    }
  }