SimpleDateFormat df= new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.sss");//db中存放Date类型数据格式
Calendar cal = Calendar.getInstance();
存储时 将Calendar 转成String 类型存放
String dateTime =df.format(cal.getTime())
读取时 将数据转成Calendar
cursor.getColumnIndex(START_TIME) //获取START_TIME字段在表中的索引
cursor.getString(cursor.getColumnIndex(START_TIME)) //数据库中取出来的date字段值
Calendar cal1= Calendar.getInstance();
cal1.setTime(df.parse(cursor.getString(cursor.getColumnIndex(START_TIME)))
原文链接:https://www.f2er.com/sqlite/202088.html