Java tutorial
//package com.java2s; //License from project: Apache License import java.text.DecimalFormat; public class Main { public static double roundTwoDecimals(double d) { DecimalFormat twoDForm = new DecimalFormat("#.#"); return Double.valueOf(twoDForm.format(d)); } }