0

I am developing an android application,in which I am getting the call- Logs.I have displayed all the details of the call Logs. The problem is I am able to get the call duration in seconds but I need it in hh-mm-ss format.

Here is the below code which I tried:

  int duration = managedCursor.getColumnIndex( CallLog.Calls.DURATION);
while ( managedCursor.moveToNext() )
{
   String callDuration = managedCursor.getString(duration);
}
LISA
  • 63
  • 2
  • 7
  • 1
    These any help? (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-e-g-format-hmmss/266970#266970) – Ken Wolf Jun 18 '13 at 07:51
  • This should help http://stackoverflow.com/questions/6118922/convert-seconds-value-to-hours-minutes-seconds-android-java – KD. Jun 18 '13 at 07:52

1 Answers1

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);
abhi
  • 759
  • 6
  • 15