2013-06-18 41 views
0

我正在开发一个android应用程序,其中我正在接听电话 - 日志。我已显示呼叫日志的所有详细信息。 问题是我可以在几秒钟内获得通话时间,但我需要它以hh-mm-ss格式。以hh-mm-ss格式呼叫记录持续时间

这里是下面的代码,我想:

int duration = managedCursor.getColumnIndex(CallLog.Calls.DURATION); 
while (managedCursor.moveToNext()) 
{ 
    String callDuration = managedCursor.getString(duration); 
} 
+1

任何帮助吗? (http://stackoverflow.com/questions/625433/how-to-convert-milliseconds-to-x-mins-x-seconds-in-java/625624#625624)(http://stackoverflow.com/questions/ 266825/how-to-format-a-duration-in-java-eg-format-h​​mmss/266970#266970) –

+0

这应该有助于http://stackoverflow.com/questions/6118922/convert-seconds-value-to- hours-minutes-seconds-android-java –

+0

@肯狼:谢谢..它帮助 – LISA

回答

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); 
这些
+0

只有代码放在没有任何文字的解释它是不好的答案 –

+0

@abhishesh:我已经完成了通话的时间。我想要通话的持续时间。 – LISA

相关问题