mongodb日期查询JAVA和Talend
我一直在使用pymongo来完成我所有的mongodb交互,不过现在,我需要从Talend运行一个查询,而不必使用python 我直接对mongodb使用以下查询:mongodb日期查询JAVA和Talend,java,json,mongodb,talend,Java,Json,Mongodb,Talend,我一直在使用pymongo来完成我所有的mongodb交互,不过现在,我需要从Talend运行一个查询,而不必使用python 我直接对mongodb使用以下查询: db.votes.find({'dateUpdated': {$gte: (new Date(new Date().setDate(new Date().getDate()-5)))}}); 只要运行date组件,我就会得到一个5天的ISODate Talend使用JAVA,我无法在那里复制查询。我得到以下错误: {'dateUp
db.votes.find({'dateUpdated': {$gte: (new Date(new Date().setDate(new Date().getDate()-5)))}});
只要运行date组件,我就会得到一个5天的ISODate
Talend使用JAVA,我无法在那里复制查询。我得到以下错误:
{'dateUpdated': {$gte: (new Date(new Date().setDate(new Date().getDate()-5)))}}
^
at com.mongodb.util.JSONParser.parse(JSON.java:198)
at com.mongodb.util.JSONParser.parseObject(JSON.java:231)
at com.mongodb.util.JSONParser.parse(JSON.java:195)
at com.mongodb.util.JSONParser.parseObject(JSON.java:231)
at com.mongodb.util.JSONParser.parse(JSON.java:195)
at com.mongodb.util.JSONParser.parse(JSON.java:145)
at com.mongodb.util.JSON.parse(JSON.java:81)
at com.mongodb.util.JSON.parse(JSON.java:66)
通过Talends UI生成的JAVA代码如下所示:
com.mongodb.DBObject myQuery_tMongoDBInput_1 = (com.mongodb.DBObject) com.mongodb.util.JSON
.parse("{'dateUpdated': {$gte: (new Date(new Date().setDate(new Date().getDate()-5)))}}");
我基本上对JAVA非常了解,但我希望有人能帮我在这个.parse函数中加入一些东西,让我的帖子更新日期超过5天
谢谢