首页 > 解决方案 > 试图将 msqlite 字符串日期转换为 java.sql.date

问题描述

我已将日期保存到 msqlite。当我检索它时,它给了我这个字符串“ Fri Jul 12 13:16:33 GMT+00:00 2019 ”。但是,我无法将其转换为java.sql.Date我需要的...任何帮助表示赞赏

        SQLiteDatabase db = this.getReadableDatabase();
        ArrayList<GraphEntry> result = new ArrayList<GraphEntry>();
        Cursor cursor = db.rawQuery("SELECT * FROM graph_table", null);
        if (cursor.moveToFirst()){
            do {
                String date = cursor.getString(cursor.getColumnIndex("date"));
                int poid = cursor.getInt(cursor.getColumnIndex("poid"));

                Log.d("date before", date);

                    GraphEntry graphEntry = new GraphEntry(date, poid);
                    result.add(graphEntry);

            } while(cursor.moveToNext());
        }
        cursor.close();
        db.close();
        return result;
 GraphEntry graphEntry = new GraphEntry(date, poid); 

告诉我

GraphEntry 中的 GraphEntry (java.sql.Date,int) 不能应用于 (java.lang.String, int)

标签: javaandroiddatetimedatetime-conversionincompatibletypeerror

解决方案


推荐阅读