New file |
| | |
| | | package com.hx.util; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | public class BigDecimalUtil { |
| | | |
| | | /**保留两位小数 |
| | | * |
| | | * @param bigDecimal 小数值 |
| | | * @return |
| | | */ |
| | | public static BigDecimal retainDecimal(BigDecimal bigDecimal){ |
| | | bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | return bigDecimal; |
| | | } |
| | | |
| | | /**保留小微小数 |
| | | * |
| | | * @param bigDecimal 小数值 |
| | | * @param decimalNum 保留小数位数 |
| | | * @return |
| | | */ |
| | | public static BigDecimal retainDecimal(BigDecimal bigDecimal,int decimalNum){ |
| | | bigDecimal.setScale(decimalNum, BigDecimal.ROUND_HALF_UP); |
| | | return bigDecimal; |
| | | } |
| | | |
| | | } |