MapLocalDateListLikesRecord mapByUser = GMmegetLikesRecordMapgetuserId; LocalDate today = LocalDatenow;年月日判断此map的键只能含有today 如果不等于today 就先清除不是今天的map保证这个map中只会有今天日期的键
Map<LocalDate, List
// 判断此map的键只能含有today,如果不等于today就先清除不是今天的map if (!mapByUser.containsKey(today)) { mapByUser.clear(); mapByUser.put(today, new ArrayList<>()); }
// 确保这个map中只会有今天日期的键 mapByUser.keySet().retainAll(Collections.singleton(today));
AI 优化版
原文地址:https://www.cveoy.top/t/topic/jgMr 著作权归作者所有。请勿转载和采集!