How to retrieve DATETIME format from Sqlite database

坚强是说给别人听的谎言 提交于 2019-12-03 12:43:55

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.

Thank you, Gopinath. Here's code that I used to perform what @Gopinath suggested:

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);

In java SimpleDateFormat

http://developer.android.com/reference/java/text/SimpleDateFormat.html

if you want millisecons anyDAteObject.getTime();

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!