Saturday 16 December 2017

Android date SQLite SimpleDateFormat Calendar

with a query, I get a value of "date" from the SQLite
database, in the format "YYYY-MM-DD". Now I want to convert this format to display the
date in the format getInstance (). How can I
do?



 DateFormat
fmtDateAndTime=DateFormat.getDateInstance();
GregorianCalendar dateAndTime =
(GregorianCalendar)
GregorianCalendar.getInstance();



I
get the date:



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

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...