title: mongodb date query JAVA and Talend
body: <p>I have been using pymongo to do all my mongodb interactions, though now, I need to run a query from Talend without going through python.</p>
  
  <p>I use the following query directly against mongodb:</p>
  
  <pre><code>db.votes.find({'dateUpdated': {$gte: (new Date(new Date().setDate(new Date().getDate()-5)))}});
  </code></pre>
  
  <p>Just running the date component gives me an ISODate thats 5 days old.</p>
  
  <p>Talend uses JAVA and I'm unable to replicate the query there. I get the below errors:</p>
  
  <pre><code>{'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)
  </code></pre>
  
  <p>The JAVA code generated through Talends UI looks like this:</p>
  
  <pre><code>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)))}}");
  </code></pre>
  
  <p>I basically know zilch of JAVA but I'm hoping someone can help me put something into that .parse function that would get me posts that have dateUpdated newer than 5 days.</p>
  
  <p>Thanks!</p>