我正在开发一个Android应用程序,我正在接收调用 - Logs.I已显示调用日志的所有详细信息。 问题是我能够在几秒钟内获得呼叫持续时间,但我需要它以hh-mm-ss格式。
以下是我尝试过的代码:
int duration = managedCursor.getColumnIndex( CallLog.Calls.DURATION);
while ( managedCursor.moveToNext() )
{
String callDuration = managedCursor.getString(duration);
}
答案 0 :(得分:0)
date = mCallCursor.getString(mCallCursor.getColumnIndex(CallLog.Calls.DATE));
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(Long.parseLong(date));
int hour = calendar.get(Calendar.HOUR_OF_DAY);
int minute = calendar.get(Calendar.MINUTE);
int seconds = calendar.get(Calendar.SECOND);
String callTime = (hour < 10 ? "0" + hour
: hour)
+ " : "
+ (minute < 10 ? "0" + minute : minute)
+ " : "
+ (seconds < 10 ? "0" + seconds
: seconds);