how can i insert datetime data in my sqlite database using contentvalues not using raw query?.
datetime('now') insert itself(text) not the time, and can i add addittional hours to the current time?
like, when i press button "1HOUR" it would insert the currenttime + 1 hour in the sqlite database..thanks, kinda confused..
将日期/时间转换为毫秒,你得到一个long.然后,您只需long在数据库中插入值.
如果它们以毫秒为单位,您可以将日期/时间值一起添加.
--EDITED--
Date myDate = new Date();
long timeMilliseconds = myDate.getTime();
//add 1 hour
timeMilliseconds = timeMilliseconds + 3600 * 1000; //3600 seconds * 1000 milliseconds
//To convert back to Date
Date myDateNew = new Date(timeMilliseconds);
Run Code Online (Sandbox Code Playgroud)
在SQLite中,java long值存储为int.