3
我在我的數據庫中將日期保存爲時間戳格式。我希望檢索特定日期的記錄(例如僅限今天的記錄)。如何格式化我的表格中存儲的格式化日期?以下是我目前的代碼:在查詢中將長日期轉換爲日期
public static long getTodayRecord(Context context, String recordId) {
long timeSpan= System.currentTimeMillis();
String currentDay = DateTimeUtil.getDisplayShortDate(currentTimespan);
String dateString= DateFormat.format("MM/dd/yyyy", new Date(currentTimespan)).toString();
String selection = "COLUMN_RECORD_ID" + " = ? AND date(" + "COLUMN_RECORD_DATE" + ") = ?";
String[] selectionArg= {recordId, dateString};
return DbUtil.count(context, "RECORD_TABLE, selection, selectionArgs);
}
任何意見是非常感謝。