如何从Sqlite数据库中检索DATETIME格式 [英] How to retrieve DATETIME format from Sqlite database

查看:101
本文介绍了如何从Sqlite数据库中检索DATETIME格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将日期(java.util.date对象)存储在Sqlite表的DATETIME字段中.现在,如何检索与java.util.date格式相同的日期.实际上,我想比较当前日期和商店日期之间的时差(以毫秒为单位).

I have stored date (java.util.date object) in a DATETIME field of a Sqlite table. Now, how to retrieve this date which would be of the same format as java.util.date. Actually I want to compare the time difference (in milliseconds) between current date and the store date.

推荐答案

以Cursor.getString()检索,并将该值传递给SimpleDateFormat以创建日期对象.没有获取日期对象的直接方法.

Retrieve as Cursor.getString() and pass that value to SimpleDateFormat to make the date object. There is no straight method for getting the date object.

这篇关于如何从Sqlite数据库中检索DATETIME格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆