I stored a value as a java.util.Date() in my collection, but when I query to get values between two specific dates, I end up getting values outside of the range. Here\'s my
Search Date with specific format following steps are that this also work in mongo 3.0
SimpleDateFormat simpleDateFormat = new SimpleDateFormat ("yyyy.MM.dd");
First convert your date in your specific format, you can use any format and parse your date with above format and then pass in query.
String date ="2014.01.02";
String data1 ="2014.01.10";
Date startDate = simpleDateFormat.parse(date);
Date endDate = simpleDateFormat.parse(date1);
BasicDBObject query = new BasicDBObject("fieldName",
new BasicDBObject("$gte",startDate).append("$lt",endDate ));
So base on your requirement you can search date by giving argument in BasicDBobject
.