我在Sqlite表的DATETIME字段中存储了date (java.util.date对象)。现在,如何检索与java.util.date格式相同的日期。实际上,我想比较当前日期和商店日期之间的时间差(以毫秒为单位)。
发布于 2012-01-25 17:05:32
作为Cursor.getString()检索,并将该值传递给SimpleDateFormat以创建date对象。没有直接的方法来获取date对象。
发布于 2013-10-25 07:40:04
谢谢你,戈皮纳特。下面是我用来执行@Gopinath建议的代码:
Calendar t = new GregorianCalendar();
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/YYYY",Locale.getDefault());
java.util.Date dt = sdf.parse(c.getString(4)); //replace 4 with the column index
t.setTime(dt);发布于 2012-01-25 16:58:27
在java SimpleDateFormat中
http://developer.android.com/reference/java/text/SimpleDateFormat.html
如果想要毫秒级的anyDAteObject.getTime();
https://stackoverflow.com/questions/8999947
复制相似问题