java stream数据分组 stream().collect(groupingBy

2021-02-16 18:17

阅读:604

标签:ping   ada   div   pre   hashmap   group   span   stream   shm   

List> foreList = forecastDataDao.getcityforeresults(param);
        Map>> timegroupby=foreList.stream().collect(groupingBy(p->p.get("citycode").toString()));
        Map>>> ret=new HashMap();
        if(timegroupby!=null){
            for(String time:timegroupby.keySet()){
                Map>> citygroup=null;
                citygroup=timegroupby.get(time).stream().collect(groupingBy(p->DateUtil.dateToStr((Date)p.get("datatime"),"yyyyMMdd")));
                if(citygroup!=null){
                    ret.put(time,citygroup);
                }
            }
        }
        return JSONObject.toJSONString(ret);

 

java stream数据分组 stream().collect(groupingBy

标签:ping   ada   div   pre   hashmap   group   span   stream   shm   

原文地址:https://www.cnblogs.com/tiandi/p/12704557.html


评论


亲,登录后才可以留言!