【发布时间】:2020-09-13 07:07:36
【问题描述】:
MongoCollection<Document> Profile_List = db.getCollection("Profile_List");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-DD");
Date todaydate = format.parse(new Date().toString());
ArrayList<Document> activeList=profile.find(Filters.regex("lastActive",todayDate.toString())).into(new ArrayList<Document>());
这是我们编写的代码。我们收到“无法解析的日期错误”。有人可以帮忙吗?
【问题讨论】:
-
我建议你不要使用
SimpleDateFormat和Date。这些类设计不佳且早已过时,尤其是前者,尤其是出了名的麻烦。而是使用来自java.time, the modern Java date and time API 的LocalDate、OffsetDateTime和/或Instant。
标签: mongodb spring-boot