Search code examples
androidcallandroid-contentprovidercalllog

Error when trying to get the date on Android CallLog.Calls


Hey I'm trying to get the date from the CallLog.Calls in Android. I'm doing like this:

import org.apache.http.impl.cookie.DateUtils;
import android.database.Cursor;
Cursor cursor = getContentResolver().query(
            android.provider.CallLog.Calls.CONTENT_URI, null, null, null,
            android.provider.CallLog.Calls.DATE + " DESC ");
 int dateId = cursor.getColumnIndex(android.provider.CallLog.Calls.DATE);
 String callDate = cursor.getString(dateId);
 String dateString = DateUtils.formatDate(callDate);

But the formatDate method doesn't allow String as parameter, it needs a Date parameter. I've tried to make a cast, but I don't think it's right. So, someone have an idea of how to do that?

Thanks.


Solution

  • Perhaps you can parse the string and get a date - http://developer.android.com/reference/java/text/DateFormat.html#parse(java.lang.String)