我有android系統數據庫的問題,因爲我的數據庫是有像2個月後從現在開始,我不能讓這樣的事情與查詢:它可能從數據庫中獲取日期?
public LiveTvProgram currentPlayedProgram(int channelID) {
LiveTvProgram program = new LiveTvProgram();
long currentTime = System.currentTimeMillis();
String selectQuery = " SELECT * FROM " + TABLE_PROGRAMS + " WHERE " +
TvContract.Programs.COLUMN_START_TIME_UTC_MILLIS + " < " + currentTime +
" AND " + TvContract.Programs.COLUMN_END_TIME_UTC_MILLIS + " > " + currentTime + " AND "
+ TvContract.Programs.COLUMN_CHANNEL_ID + " = " + channelID;
Cursor cursor = myDataBase.rawQuery(selectQuery, null);
if(cursor != null && cursor.moveToFirst()){
program = LiveTvProgram.fromCursor(timeDifference, cursor);
cursor.close();
}
return program;
}
所以當我做這樣的我只能記錄與今天00:00,和everthing是這樣的。它不需要這樣做,但我想問你,是否有可能從數據庫中獲取時間並執行此操作?
您是否試圖獲取數據庫的日期時間並將其返回給應用程序? – Takarii
我不能調用類似myDatabase.getTime或getDate – Genehme
來獲得當前的日期時間,你會想'DATETIME('now')' – Takarii