Java BigDecimal转Integer
作者:
东本三月 | 来源:发表于
2021-10-14 16:12 被阅读0次 /**
* Map里的数据,如果值为BigDecimal类型,转为Integer
* @param maps
* @return
*/
public static Map mapBigDecimalToInteger(Map maps){
if(maps==null){
return maps;
}
if(maps.isEmpty()){
return maps;
}
for (Object key : maps.keySet()) {
Object value=maps.get(key);
if(value instanceof BigDecimal ){
BigDecimal value_bd=(BigDecimal)value;
value_bd=value_bd.setScale( 0, BigDecimal.ROUND_DOWN );
Integer value_int=Integer.parseInt(value_bd.toString());
maps.put(key,value_int);
}
}
return maps;
}
本文标题:Java BigDecimal转Integer
本文链接:https://www.haomeiwen.com/subject/wpluoltx.html
网友评论