List<TeamScheduleDTO> list = JSON.parseArray(response.getData().getJSONArray("list").toJSONString(), TeamScheduleDTO.class);
// guava写法
/* Map<String, List<TeamScheduleDTO>> allMap = Multimaps.asMap(Multimaps.index(list1,
new Function<TeamScheduleDTO, String>() {
@Override
public String apply(TeamScheduleDTO input) {
String dateStr = DateFormatUtils.format(input.getMatchDateTime(), "yyyy-MM-dd");
return dateStr;
}
}));*/
// jdk8写法
Map<String, List<TeamScheduleDTO>> allMap = list1.stream().collect(Collectors.groupingBy(input -> DateFormatUtils.format(input.getMatchDateTime(), "yyyy-MM-dd")));
List<String> dateList = new ArrayList<>();
for (Map.Entry<String, List<TeamScheduleDTO>> entry : allMap.entrySet()) {
dateList.add(entry.getKey());
}
dateList.sort((o1, o2) ->
DateUtils.toDate(o1).compareTo(DateUtils.toDate(o2)));
List<TeamScheduleReturnDTO> returnDTOList = new ArrayList<>(); for (String str : dateList) {
TeamScheduleReturnDTO dto = new TeamScheduleReturnDTO();
dto.setShowDate(str);
dto.setRelScheduleList(allMap.get(str));
returnDTOList.add(dto);
}
return returnDTOList;

List<DTO>转 Map<String,List<DTO>> 两种写法的更多相关文章

  1. 初始化map和list的两种写法

    第一种方法(常用方法): //初始化List List list = new ArrayList(); list.add("string1"); list.add("st ...

  2. 菜鸡的Java笔记 第十三 String 类的两种实例化方法

    String 类的两种实例化方法 String 类的两种实例化方式的区别 String 类对象的比较 Stirng 类对象的使用分析 /*    1.String 类的两种实例化方式的区别       ...

  3. EF架构~linq模拟left join的两种写法,性能差之千里!

    回到目录 对于SQL左外连接我想没什么可说的,left join将左表数据都获出来,右表数据如果在左表中不存在,结果为NULL,而对于LINQ来说,要实现left join的效果,也是可以的,在进行j ...

  4. java 路径分隔符File.separator 以及 路径两种写法"/"和"\\"

    一.File.separator File file=new File(); 这句是新建一个文件.file.separator这个代表系统目录中的间隔符,说白了就是斜线,不过有时候需要双线,有时候是单 ...

  5. linq和ef关于group by取最大值的两种写法

    LINQ: var temp = from p in db.jj_Credentials group p by p.ProfessionID into g select new { g.Key, Ma ...

  6. 关于MyBatis的两种写法

    刚接触MyBatis是在Jike的视频中学习的,但是之后又发现和项目中的MyBatis的用法不太一致.上网找了好多资料,发现网上的教程分为两种写法: 第一种,是jike视频中的写法,写好map.xml ...

  7. Sql语句模糊查询字符串的两种写法

    Sql语句模糊查询有两种写法,一种是在jdbcTemplate的查询方法参数里拼接字符串%,一种是在Sql语句里拼接%字符串. public class IsNameDaoImpl implement ...

  8. SpringBoot java配置类@Configuration 的两种写法

    首先在Springboot项目中,件一个java类,使用注解@Configuration  ,则这个类是SpringBoot bean的创建的配置文件类,,这种配置文件类有两种写法 1.使用包扫描 , ...

  9. ORACLE 查询一个数据表后通过遍历再插入另一个表中的两种写法

    ORACLE 查询一个数据表后通过遍历再插入另一个表中的两种写法 语法 第一种: 通过使用Oracle语句块  --指定文档所有部门都能查看 declare cursor TABLE_DEPT and ...

随机推荐

  1. umask文件屏蔽字的使用【学习笔记】

    #include "apue.h" #include <fcntl.h> #define RWRWRW (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP ...

  2. vue开发购物车,解决全选单选问题

    实现全选单选,在vue中无法通过this获取input中的checkbox的checked属性,但是可以通过vue对input的特殊方式v-model来实现对应数据的绑定,同样也可以通过这种方式实现购 ...

  3. SpringBoot发送简单文本邮件

    1.pom.xml添加 spring-boot-starter-mail 依赖 <dependency> <groupId>org.springframework.boot&l ...

  4. golang copy函数

    数组切片内容复制 转自:http://studygolang.com/articles/4560 用于将内容从一个数组切片复制到另一个数组切片.如果加入的两个数组切片不一样大,就会按其中较小的那个数组 ...

  5. codeforces 691C C. Exponential notation(科学计数法)

    题目链接: C. Exponential notation time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  6. [Selenium] 使用自定义的FirefoxProfile

    FirefoxProfile 用于定制待测试的Firefox 浏览器的特定属性,其中包括所存储的密码.书签.历史信息.Cookies等.某些测试用例需要用到特定的用户信息,因此可通过定制当前Firef ...

  7. "Activity" 总结

    1.什么是Activity? 1.四大组件之一 2.通常一个界面对应一个activity 3.是Context的子类 4.同时实现window.callback和keyevent.callback回调 ...

  8. RobotFramework:App滑动屏幕

    转自:http://blog.csdn.net/jgw2008/article/details/77993399 在使用Robot Framework测试Android机器过程中, 经常要用到滚屏操作 ...

  9. 6-10 SVM支持向量机1

    都是特征加上分类器.还将为大家介绍如何对这个数据进行训练.如何训练得到这样一组数据. 其实SVM支持向量机,它的本质仍然是一个分类器.既然是一个分类器,它就具有分类的功能.我们可以使用一条直线来完成分 ...

  10. List集合与Array数组之间的互相转换

    1.数组转换成List集合 采用java中集合自带的asList()方法就可以完成转换了 String[] array = new String[] {"zhu", "w ...