Reputation: 61
I am developing an application in which I need to get the last sent SMS. All good so I'll know the date of shipment. With the expression int cursor.getColumnIndex indexDate = (DATE) I get an integer but I need to convert a date eses integer format dd / MM / yyyy and then convert that date to String. How I would do?. Thanks in advance.
Upvotes: 2
Views: 7282
Reputation: 487
try this:
int dateColumn = cursor.getColumnIndex("date"); //integer represent date you get from db
Date d = new Date(Long.parseLong(cursor.getString(dateColumn)));
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd " + "\n" + "hh:mm:ss");
String date = dateFormat.format(d); // formatted date in string
Upvotes: 9