1
我想從Java到mongoDB的日期進行比較,如下所示。但它無法正常工作。java到mongoDB日期在哪裏條款
Java代碼:
Calendar calendar1 = Calendar.getInstance();
calendar1.setTime(new java.util.Date());
calendar1.set(Calendar.HOUR_OF_DAY, 00);
calendar1.set(Calendar.MINUTE, 00);
calendar1.set(Calendar.SECOND, 00);
calendar1.set(Calendar.MILLISECOND, 000);
Date a1 = new Date();
a1 = calendar.getTime();
MongoDatabase database = mongo.getDatabase("dummy");
MongoCollection<Document> dbCollection= database.getCollection("something");
long count = dbCollection.count(Filters.and(Filters.gte("startTime", a1)));
蒙戈DB系列
{
"_id" : ObjectId("586cd802de77f23f"),
"name" : "sim",
"serverity" : "high",
"startTime" : ISODate("2017-01-04T11:11:32.058Z")
}
在比較中使用新的日期(a1),Filters.gte(「startTime」,a1),您使用新的日期(a1) – gaston
使用的問題是,我需要獲取開始時間(午夜) a1和endtime(午夜)也。所以新的日期(a1)未被使用。 – user2000189
使用a1 = calendar1.getTime(); – Veeram