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
。请告诉我如何转换
答案 0 :(得分: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;
}
答案 1 :(得分:0)
像这样编写自己的ALgo
s = (ms / 1000) % 60;
m = (ms / (1000 * 60)) % 60;
h = (ms / (1000 * 60 * 60)) % 24;
并最终将它们作为您的愿望附加。