qq_15143807
Voiss
采纳率100%
2018-12-05 12:12 阅读 1.1k
已结题

JAVA一个复合的LIST如何合并

List<Map<String, Object>>

[
        {
            "todaysharecount": 0,
            "activetime": "2018-12-03",
            "todayjoincount": 0,
            "todayactivecount": 1
        },
        {
            "sharetime": "2018-12-05",
            "todayjoincount": 0,
            "todaysharecount": 2,
            "todayactivecount": 9,
            "activetime": "2018-12-05"
        },
        {
            "todayjoincount": 0,
            "todaysharecount": 2,
            "sharetime": "2018-11-29",
            "todayactivecount": 0
        },
        {
            "todayjoincount": 0,
            "todaysharecount": 2,
            "sharetime": "2018-12-01",
            "todayactivecount": 0
        },
        {
            "todayjoincount": 0,
            "todaysharecount": 2,
            "sharetime": "2018-12-02",
            "todayactivecount": 0
        },
        {
            "todaysharecount": 0,
            "todayjoincount": 4,
            "jointime": "2018-11-23",
            "todayactivecount": 0
        },
        {
            "todaysharecount": 0,
            "todayjoincount": 1,
            "jointime": "2018-11-27",
            "todayactivecount": 0
        },
        {
            "todaysharecount": 0,
            "jointime": "2018-11-30",
            "todayjoincount": 4,
            "todayactivecount": 0
        },
        {
            "todaysharecount": 0,
            "todayjoincount": 2,
            "jointime": "2018-12-03",
            "todayactivecount": 0
        }
    ]

这样一个LIST 怎么做到合并日期 每个Map里值大概都是这样 按照日期排序

    {
                    "time": "2018-12-03",
        "todaysharecount": 0,
        "todayjoincount": 2,
        "todayactivecount": 0
    }
  • 点赞
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    qq_16127313 爱码少年 2018-12-06 01:11

    简单来说:构造一个以时间yyyy-MM-dd为key,包含

    "time": "2018-12-03",
    "todaysharecount": 0,
    "todayjoincount": 2,
    "todayactivecount": 0
    值内容的ConcurrentHashMap,遍历复合List,来操作Map,具体的操作不是太难就不详细展开了!

    点赞 1 评论 复制链接分享
  • caozhy 从今以后生命中的每一秒都属于我爱的人 2018-12-05 14:14

    具体你要做什么不是很清楚,为什么合并以后的日期是12-03了。

    建议你先看下这个:https://blog.csdn.net/beirdu/article/details/78585945

    点赞 1 评论 复制链接分享

相关推荐