| | |
| | | package com.hx.util; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | |
| | | return null == map.get(key) ? -1 : Integer.parseInt(map.get(key).toString()); |
| | | } |
| | | |
| | | /** |
| | | * 从map中获取整数,如果没有,则返回0 |
| | | * @param map |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public static int getIntZero(Map<String, Object> map, String key) |
| | | { |
| | | if(map == null || StringUtils.isEmpty(key)) |
| | | { |
| | | return 0; |
| | | } |
| | | |
| | | return null == map.get(key) ? 0 : Integer.parseInt(map.get(key).toString()); |
| | | } |
| | | |
| | | /** |
| | | * 从map中获取数字类型对象 |
| | | * @param map |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public static BigDecimal getBigDecimal(Map<String, Object> map, String key) |
| | | { |
| | | if(map == null || StringUtils.isEmpty(key)) |
| | | { |
| | | return BigDecimal.ZERO; |
| | | } |
| | | |
| | | return null == map.get(key) ? BigDecimal.ZERO : new BigDecimal(map.get(key).toString()); |
| | | } |
| | | |
| | | /** |
| | | * 获取浮点数,默认返回0 |
| | | * @param map |
| | | * @param key |
| | | * @return |
| | | */ |
| | | public static Double getDoubleZero(Map<String, Object> map, String key) |
| | | { |
| | | if(map == null || StringUtils.isEmpty(key)) |
| | | { |
| | | return 0D; |
| | | } |
| | | |
| | | return null == map.get(key) ? 0D : Double.parseDouble(map.get(key).toString()); |
| | | } |
| | | } |