title: MongoDB: Query using $gte and $lte in java
body: <p>I want to perform a query on a field that is greater than or equal to, AND less than or equal to(I'm using java btw). In other words. >= and &lt;=. As I understand, mongoDB has $gte and $lte operators, but I can't find the proper syntax to use it. The field i'm accessing is a top-level field.</p>
  
  <p>I have managed to get this to work: </p>
  
  <pre><code>FindIterable&lt;Document&gt; iterable = db.getCollection("1dag").find(new Document("timestamp", new Document("$gt", 1412204098)));
  </code></pre>
  
  <p>as well ass...</p>
  
  <pre><code>FindIterable&lt;Document&gt; iterable = db.getCollection("1dag").find(new Document("timestamp", new Document("$lt", 1412204098)));
  </code></pre>
  
  <p>But how do you combine these with each other?</p>
  
  <p>Currently I'm playing around with a statement like this, but it does not work:</p>
  
  <pre><code>FindIterable&lt;Document&gt; iterable5 = db.getCollection("1dag").find(new Document( "timestamp", new Document("$gte", 1412204098).append("timestamp", new Document("$lte",1412204099))));
  </code></pre>
  
  <p>Any help?</p>