Java examples for java.math:BigDecimal Calculation
round BigDecimal Half Up To DP
//package com.java2s; import java.math.BigDecimal; import java.math.RoundingMode; public class Main { public static void main(String[] argv) throws Exception { BigDecimal input = new BigDecimal("1234"); System.out.println(roundHalfUpTo2DP(input)); }//from w ww . ja v a2 s. c o m public static BigDecimal roundHalfUpTo2DP(BigDecimal input) { return input.setScale(2, RoundingMode.HALF_UP); } public static BigDecimal roundHalfUpTo2DP(Double input) { return roundHalfUpTo2DP(BigDecimal.valueOf(input)); } }