MongoDB DateTime格式 [英] MongoDB DateTime Format

查看:578
本文介绍了MongoDB DateTime格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在mongodb addhoc查询中,在执行查询之前,如何将日期类型元素格式化为dd\mm\yyyy格式,然后执行查询?

In mongodb adhoc query, before executing the query, how to format the date type element to dd\mm\yyyy format and then execute the query?

推荐答案

我通过使用Java中的getTime()方法将日期时间作为整数插入来解决了这一问题. EG:

I solved this by inserting the datetime as integer using the getTime() method in java. EG:

Date dt=new Date();
long integer_date=dt.getTime();

我使用上面的代码行将日期插入为整数,因此很容易在特定日期之间获取记录.

I used the above line of code to insert date as integer.With this it was easy to fetch records between a particular date.

这篇关于MongoDB DateTime格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆