直接用代碼表示吧,留意BasicDBList使用就行了
DBObject query = new BasicDBObject();
query.put("agent_id", 511);
query.put("switchSn", "交96");
query.put("ds_name", "trafficin_eth0");
query.put("relay_ip", "192.168.239.176");
BasicDBList values = new BasicDBList();
values.add(new BasicDBObject("time", new BasicDBObject("$gte", DateUtil.getInstance().getDateTimeStrMultiThread("2011-07-24 00:00:00").getTime()).append("$lte", DateUtil.getInstance().getDateTimeStrMultiThread("2011-07-27 23:59:59").getTime())));
values.add(new BasicDBObject("time", new BasicDBObject("$gte", DateUtil.getInstance().getDateTimeStrMultiThread("2011-07-28 00:00:00").getTime()).append("$lte", DateUtil.getInstance().getDateTimeStrMultiThread("2011-07-29 23:59:59").getTime())));
query.put("$or", values);