0
String callTime = secondsToDisplayableString(log.getCallDuration());
String callDate = String.valueOf(log.getTimestamp());

private String secondsToDisplayableString(int secs) {

    SimpleDateFormat data = new SimpleDateFormat("HH:mm:ss");

    Calendar cal = Calendar.getInstance();

    cal.set(0, 0, 0, 0, 0, secs);

    return data.format(cal.getTime());  

}`

my output is in sec .i want to convert into hh.mm.ss .my code is using timestamp date and time .please tell me how can i convert

Vaibs_Cool
  • 6,126
  • 5
  • 28
  • 61

2 Answers2

0

Try This

public static int[] splitToComponentTimes(BigDecimal yousecoutput)
{
    long longVal = yousecoutput.longValue();
    int hours = (int) longVal / 3600;
    int remainder = (int) longVal - hours * 3600;
    int mins = remainder / 60;
    remainder = remainder - mins * 60;
    int secs = remainder;

    int[] ints = {hours , mins , secs};
    return ints;
}
Vaibs_Cool
  • 6,126
  • 5
  • 28
  • 61
0

Write your own ALgo like this

s = (ms / 1000) % 60;
m = (ms / (1000 * 60)) % 60;
h = (ms / (1000 * 60 * 60)) % 24;

and in the end append them as your wish.

Jitender Dev
  • 6,907
  • 2
  • 24
  • 35