我正在使用两个时间戳last_edited
和last_uploaded
来判断是否需要将SQLite条目上传到我的服务器。但是,即使我在更新这些时间戳时使用datetime('now'),last_uploaded
中的时间戳也会保存为我的本地时间(UTC +2)。
关于为什么会这样或者我如何解决它的任何想法?
我的SQLite语句是:
private static final String UPDATE_EDITED_TIMESTAMP_BY_ID =
"UPDATE " + TABLE_ENTRIES + "\n"
+ "SET " + COLUMN_ENTRIES_LAST_EDITED + " = DATETIME('now')\n"
+ "WHERE " + COLUMN_ENTRIES_ID + " = :id;";
private static final String UPDATE_SYNC_INFO_BY_ID =
"UPDATE " + TABLE_WORK_ENTRIES + "\n"
+ "SET " + COLUMN_ENTRIES_LAST_SYNCED + " = DATETIME('now'), " + COLUMN_ENTRIES_SERVER_ID + " = :server_id\n"
+ "WHERE " + COLUMN_ENTRIES_ID + " = :db_id;";
当我运行它们时,我使用的代码如下:
String sql = UPDATE_EDITED_TIMESTAMP_BY_ID.replace(":id", Integer.toString(id));
db.execSQL(sql);