如何从map中提取value并转换成long

old:

taskReportDataDTO.setUv(Long.valueOf(hbaseData.get(HbaseColumnEnum.uv).toString()));

 

 new:

taskReportDataDTO.setPv(MapUtils.getLong(hbaseData, HbaseColumnEnum.pv.name().toLowerCase(), 0L));

 

http://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/MapUtils.html

static <K> Long getLong(Map<? super K,?> map, K key, Long defaultValue)
Looks up the given key in the given map, converting the result into a long, using the default value if the the conversion fails.
原文地址:https://www.cnblogs.com/iwangzheng/p/8744080.html