标签:mon tor operator str pre god ssi lis count
mongodb的默认时间是格林尼治时间,如果是要按照日期进行分组需要注意!!!。
解决方案:
Aggregation.project().and("createTime").dateAsFormattedString("%Y-%m-%d").as("time"),
Aggregation.group("time").count().as("count")
或者
Aggregation.project().and(DateOperators.DateToString.dateOf("createTime").toString("%Y-%m-%d")).as("name"),
Aggregation.group("time").count().as("count")
dateAsFormattedString()方法会默认将当前时间转为系统默认的时区
Aggregation.project().andExpression("add(createTime,28800000)").as("time"),
Aggregation.group("time").count().as("count")
标签:mon tor operator str pre god ssi lis count
原文地址:https://www.cnblogs.com/xibuhaohao/p/12076823.html