尝试将msqlite字符串日期转换为java.sql.date

时间:2019-07-12 14:35:23

标签: java android datetime datetime-conversion incompatibletypeerror

我已将日期保存到msqlite。当我检索到它时,它会给我这个字符串“ 星期五7月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)

0 个答案:

没有答案