• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to convert CallLog.calls.DATE into dateFormat?

saranya

Lurker
Oct 17, 2008
9
1
public static Date formatDate(String dateString){
Date callDate=new Date();
try{
callDate=DateUtils.parseDate(dateString);
}catch(Exception e){
Log.v("CallLog","Exception in FormatDate"+e.getMessage());
}
return callDate;
}
I am using this method to get date format.But it show me the exception
like this: VERBOSE/CallLog(530): Exception in FormatDateUnable to parse the date 429578575
int callDate = callcur.getInt(dateColumn);
Date date=new Date();
dateStr=dateStr.valueOf(callDate);
date=formatDate(String.valueOf(dateStr));
In this way i passed the value from android.provider.CallLog.calls.DATE
So please tell me mistake I did in this.And how to correct that
Thanks in advance
saran
 
From what package is the static DateUtils.parseDate(dateString) you are using? I have a feeling you are using the org.apache.http.impl.cookie.DateUtils version which is meant to parse html date formats.

I don't have a compiler in front of me to try, but I suspect that the android.provider.CallLog.calls.DATE is a millisecond format that could just get passed to the java.util.Date(long millisecondTime) constructor.

Try this:
Code:
int callDate = callcur.getInt(dateColumn);
Date date=new Date(callDate);
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones