如何根据当前日期过滤记录?

我正在实现一个功能,我以字符串形式存储日期,并使用 LocalDate 函数获取字符串中的当前日期,因此我想比较两个日期,我想仅获取当前日期记录。


未发现错误,但无法获取记录。


  public ArrayList<Followup_Model> followup_reminder (ArrayList<Followup_Model> followup_Model_list) {

    if (followup_Model_list == null) {

        followup_Model_list = new ArrayList<>();

    }

    SQLiteDatabase sqLiteDatabase = this.getReadableDatabase();

    DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd");

    LocalDate localDate = LocalDate.now();

    String Today = dtf.format(localDate);

    Cursor followup_output = sqLiteDatabase.rawQuery("SELECT * FROM " + Table_Name_Followup +

            " WHERE CREATEDBY = '1' AND CHECKED = '1' AND STARTDATE = " + Today +

            " ORDER BY REMINDER ASC",null);


繁星点点滴滴
浏览 73回答 1
1回答

繁华开满天机

只需复制并粘贴即可。public ArrayList<Followup_Model> followup_reminder (ArrayList<Followup_Model>&nbsp;&nbsp;followup_Model_list) {&nbsp; &nbsp; if (followup_Model_list == null) {&nbsp; &nbsp; &nbsp; &nbsp; followup_Model_list = new ArrayList<>();&nbsp; &nbsp; }&nbsp; &nbsp; SQLiteDatabase sqLiteDatabase = this.getReadableDatabase();&nbsp; &nbsp; DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd");&nbsp; &nbsp; LocalDate localDate = LocalDate.now();&nbsp; &nbsp; String Today = dtf.format(localDate);&nbsp; &nbsp; Cursor followup_output = sqLiteDatabase.rawQuery("SELECT * FROM " + Table_Name_Followup +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; " WHERE CREATEDBY = '1' AND CHECKED = '1' AND STARTDATE = '" + Today + "'" +&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; " ORDER BY REMINDER ASC",null);
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java