产品要求页面金额展示时要去除多余的零:1.25展示1.25,1.20展示1.2,1.00 展示1。
public static String wipeBigDecimalZero(BigDecimal number) { NumberFormat nf = NumberFormat.getInstance(); return nf.format(number); } public static void wipeMapBigDecimalZero(Mapmap) { for(Map.Entry entry:map.entrySet()) { if(entry.getValue() instanceof BigDecimal) { map.put(entry.getKey(), NumberFormatUtil.wipeBigDecimalZero((BigDecimal)entry.getValue())); } } } public static void wipeListOrMapBigDecimalZero(Object collection) { if(collection instanceof Map) { Map map = (Map )collection; for(Map.Entry entry:map.entrySet()) { if(entry.getValue() instanceof BigDecimal) { map.put(entry.getKey(), NumberFormatUtil.wipeBigDecimalZero((BigDecimal)entry.getValue())); } } } if(collection instanceof List) { List