package com.test; import java.text.DecimalFormat; public class Test_round { /** * @param args */ public static void main(String[] args) { DecimalFormat dcmFmt = new DecimalFormat("0.00"); // dcmFmt.format(12.222) System.out.println( dcmFmt.format(12.227)); } } public static Double round(Double value, int scale) { double result = 0.0; if (null != value) { result = new BigDecimal(String.valueOf(value)).setScale(scale, RoundingMode.HALF_UP).doubleValue(); } return result; }