What you’re doing is querying only with {$lte: toDate}
losing $gte
operator in the key overwrite. What you want is:
query.put("dateAdded", BasicDBObjectBuilder.start("$gte", fromDate).add("$lte", toDate).get());
More Related Contents:
- Convert Date/Time for given Timezone – java
- Convert java.util.Date to what “java.time” type?
- SimpleDateFormat producing wrong date time when parsing “YYYY-MM-dd HH:mm”
- ‘Field required a bean of type that could not be found.’ error spring restful API using mongodb
- How to convert a String to a Date using SimpleDateFormat?
- Unable to obtain LocalDateTime from TemporalAccessor when parsing LocalDateTime (Java 8)
- How to get milliseconds from LocalDateTime in Java 8
- What is the use of “lenient “?
- How to change TIMEZONE for a java.util.Calendar/Date
- In Java, how do I get the difference in seconds between 2 dates?
- How can I create a Java 8 LocalDate from a long Epoch time in Milliseconds?
- last day of month calculation
- Comparing time is incorrect when picking 12:00
- Mocking time in Java 8’s java.time API
- How to compare two dates along with time in java
- Mongodb Increment value inside nested array
- How to do a Mongo aggregation query in Spring Data?
- How to transform currentTimeMillis to a readable date format? [duplicate]
- How to convert date time from one time zone to another time zone
- MongoDB $aggregate $push multiple fields in Java Spring Data
- Java Best Practice for Date Manipulation/Storage for Geographically Diverse Users
- Convert date into AEST using java
- Java String to DateTime
- Time: How to get the next friday?
- How do I get localized date pattern string?
- Set MongoDb converter programmatically
- A datetime equivalent in java.sql ? (is there a java.sql.datetime ?)
- MongoDB Composite Key
- How to combine date and time into a single object?
- TransactionRequiredException Executing an update/delete query