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());  

}`

我的输出在sec.我想转换成.我的hh.mm.ss代码正在使用.timestamp date and time请告诉我如何转换

4

2 回答 2

0

尝试这个

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;
}
于 2013-10-03T07:42:13.543 回答
0

像这样写你自己的算法

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

最后按照您的意愿附加它们。

于 2013-10-03T07:42:28.403 回答