TimeStamp Difference Between Java and SQLite

前端 未结 2 932
北海茫月
北海茫月 2021-01-21 15:38

Hello I have and SLQLite database in which I have table water_logs

CREATE TABLE water_logs( 
_id INTEGER PRIMARY KEY AUTOINCREMENT,
amount REAL NOT NULL,
icon IN         


        
2条回答
  •  一个人的身影
    2021-01-21 16:16

    Seems to me that you are using 2 different value types.

    When you use

    Calendar cal = Calendar.getInstance(); 
    long time = cal.getTimeInMillis();
    

    The output value is in Milliseconds, as described here.

    While when you use

    strftime('%s','now')
    

    The output value is in Seconds, as described here.

    So, that might be the cause for the mismatch between the two values. Of course that the value in seconds might undergo some rounding which might change its value a little.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题