Here you can find the source of toBigDecimal(Integer num)
public static BigDecimal toBigDecimal(Integer num)
//package com.java2s; //License from project: Open Source License import java.math.BigDecimal; import java.math.RoundingMode; public class Main { public static BigDecimal toBigDecimal(Integer num) { try {/*from w w w.j a v a 2s . co m*/ return roundBigDecimal(new BigDecimal(num)); } catch (Exception ignored) { } return null; } public static BigDecimal toBigDecimal(Double num) { try { return roundBigDecimal(new BigDecimal(num)); } catch (Exception ignored) { } return null; } public static BigDecimal toBigDecimal(Float num) { try { return roundBigDecimal(new BigDecimal(num)); } catch (Exception ignored) { } return null; } public static BigDecimal toBigDecimal(String num) { try { return roundBigDecimal(new BigDecimal(num)); } catch (Exception ignored) { } return null; } public static BigDecimal toBigDecimal(String num, Integer scale) { try { return roundBigDecimal(new BigDecimal(num), scale); } catch (Exception ignored) { } return null; } public static BigDecimal toBigDecimal(Object num) { try { return roundBigDecimal(num != null ? new BigDecimal(num.toString()) : null); } catch (Exception ignored) { } return null; } public static BigDecimal roundBigDecimal(BigDecimal num) { return roundBigDecimal(num, 2); } public static BigDecimal roundBigDecimal(BigDecimal num, int scale) { if (num != null) { return num.setScale(scale, RoundingMode.HALF_UP); } return num; } }