| | |
| | | public class CurrencyUtil { |
| | | |
| | | public static BigDecimal convertFenToYuan(long price) { |
| | | return new BigDecimal(price).divide(new BigDecimal(100)); |
| | | return new BigDecimal(price).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN); |
| | | } |
| | | |
| | | public static Integer convertFenToYuan(Integer price) { |
| | | |
| | | public static double convertFenToYuan(Integer price) { |
| | | if (price == null) { |
| | | return null; |
| | | return 0; |
| | | } |
| | | return new BigDecimal(price).divide(new BigDecimal(100)).intValueExact(); |
| | | return new BigDecimal(price).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN).doubleValue(); |
| | | } |
| | | |
| | | public static BigDecimal convertFenToYuan(BigDecimal price) { |
| | | |
| | | public static double convertFenToYuan(Double price) { |
| | | if (price == null) { |
| | | return null; |
| | | return 0; |
| | | } |
| | | return price.divide(new BigDecimal(100)); |
| | | return BigDecimal.valueOf(price).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_DOWN).doubleValue(); |
| | | } |
| | | } |