加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

在SQLite中保存datetime类型的最好方法是什么?

发布时间:2020-12-12 19:20:00 所属栏目:百科 来源:网络整理
导读:我正在创建Android应用,需要保存创建记录的日期/时间。什么是最好的方法呢?我将需要比较它以后。例如,在我的应用程序中,我将显示所有记录是在日期A到日期B之间创建的。 SQlite没有特定的datetime类型。您可以使用TEXT,REAL或INTEGER类型,任何适合您的
我正在创建Android应用,需要保存创建记录的日期/时间。什么是最好的方法呢?我将需要比较它以后。例如,在我的应用程序中,我将显示所有记录是在日期A到日期B之间创建的。 SQlite没有特定的datetime类型。您可以使用TEXT,REAL或INTEGER类型,任何适合您的需要。

直接从DOCS

SQLite does not have a storage class set aside for storing dates and/or times. Instead,the built-in Date And Time Functions of SQLite are capable of storing dates and times as TEXT,REAL,or INTEGER values:

  • TEXT as ISO8601 strings (“YYYY-MM-DD HH:MM:SS.SSS”).
  • REAL as Julian day numbers,the number of days since noon in Greenwich on November 24,4714 B.C. according to the proleptic Gregorian calendar.
  • INTEGER as Unix Time,the number of seconds since 1970-01-01 00:00:00 UTC.

Applications can chose to store dates and times in any of these formats and freely convert between formats using the built-in date and time functions.

SQLite内置的日期和时间功能可以是found here

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读