0

我将以下对象存储在菜单集合中。然后我进行以下查询,它没有找到任何记录。请帮忙。

提前致谢。

>> Menu.java
    private String menuId;
    private Date startDate;
    private Date endDate;

>> Store.java
    DBCollection collection = db.getCollection(collectionType);
    String jsonString = new Gson().toJson(object);
    DBObject dbObj = (DBObject) JSON.parse(jsonString);
    collection.save(dbObj);

>> String generated is
{"menuId":"1","startDate":"Jul 12, 2013 8:52:48 AM","endDate":"Jul 22, 2013 8:52:48 AM"}

>> Query defined for startDate < currentdate < endDate
    BasicDBObject query = new BasicDBObject("startDate", new BasicDBObject("$lte", AbstractJson.getDate(days))).append("endDate", new BasicDBObject("$gte", AbstractJson.getDate(days)));

{ "startDate" : { "$lte" : { "$date" : "2013-07-17T13:02:56.697Z"}} , "endDate" : { "$gte" : { "$date" : "2013-07-17T13:02:58.510Z"}}}
4

1 回答 1

0

谢谢米格尔。现在我们决定以长期价值存储时间。所以现在可以了。

于 2013-08-24T20:59:18.637 回答