下载吧 - 绿色安全的游戏和软件下载中心

软件下载吧

当前位置:软件下载吧 > 数据库 > DB2 > Mongodb 如何将时间戳转换为年月日日期

Mongodb 如何将时间戳转换为年月日日期

时间:2024-03-09 11:51作者:下载吧人气:30

Mongodb将时间戳转换为年月日日期

使用dateToString 方法进行转换 并且通过format指定转换日期格式

        Integer userId=aaa;
        GroupOperation groupOperation = Aggregation.group(“day”).sum(“money”).as(“todayIncome”).count().as(“todayPayCount”);
        Aggregation aggregation = Aggregation.newAggregation(
                Aggregation.match(Criteria.where(“userId”).is(userId)),
                project(“userId”,”money”).andExpression(“{$dateToString: {date: { $add: {‘$createTime’, [0]} }, format: ‘%Y%m%d’}}”, new Date(28800000)).as(“day”),
                groupOperation,
                sort(Sort.Direction.ASC, “_id”)
        );
标签Mongodb,nbsp,如何,时间,转换,年月日,日期

相关下载

查看所有评论+

网友评论

网友
您的评论需要经过审核才能显示

热门阅览

最新排行

公众号