【发布时间】:2014-08-12 17:03:14
【问题描述】:
通过查询,我从 SQLite 数据库中获得了“日期”值,格式为“YYYY-MM-DD”。现在我想把这种格式转换成getInstance()格式显示日期。我该怎么办?
DateFormat fmtDateAndTime=DateFormat.getDateInstance();
GregorianCalendar dateAndTime = (GregorianCalendar) GregorianCalendar.getInstance();
我知道日期了:
private void Mto() {
String id_ricevuto = (i.getStringExtra("id_p"));
SQLiteDatabase db = mHelper.getReadableDatabase();
String tabella = "SELECT _id, date FROM Table1 WHERE _id = '"+id_ricevuto+"'";
Cursor c = db.rawQuery(tabella, null);
while (c.moveToNext()){
String id = c.getString(0);
String date = c.getString(1);
//here I want to convert the data before displaying it in the TextView
idw.setText(id);
mBtnPickDate.setText(date);
}
c.close();
db.close();
}
【问题讨论】:
-
发布完整代码,包括从数据库中获取值的位置。
-
我编辑了我的帖子。谢谢
标签: android sqlite date calendar