Skip to content Skip to sidebar Skip to footer

Convert Int To Date Format Dd / Mm / Yyyy In Android

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

Solution 1:

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

Post a Comment for "Convert Int To Date Format Dd / Mm / Yyyy In Android"