如何比较当前系统时间与android数据库中存储的时间? 我用这个代码:比较当前系统的日期和时间与数据和时间库中存储的日期android
public static long s ;
.
.
.
.
Time now = new Time();
now.setToNow();
String query = "SELECT Cart_ID,Cart_Date from Tbl_Cart where Cart_ID="+lastId+" ";
// String queryt = "SELECT Cart_Date from Tbl_Cart where Cart_ID="+lastId+" ";
Cursor c = db.rawQuery(query, null);
if (c != null && c.moveToFirst()) {
s = c.getLong(0);
}
if(s==now.setToNow())
{
...
}
会将System.currentTimeMillis()用于日期吗? – shadi
是的。但是请注意,如果您打算将其与日期进行比较,那么您也正在使用日历。 –
我在数据库中自动存储日期(当前系统日期型日期时间),我不需要日历,我这样做:String query =“SELECT Cart_Status,Cart_ID,Cart_Date from Tbl_Cart where Cart_ID =”+ lastId +“”; Cursor c = db.rawQuery(query,null); S2 = c.getLong(1); System.currentTimeMillis的()!= S2) – shadi