2

I´ve a time measure system in my app and where I have my milliseconds in a LONG datatype.

Now, I want them to convert into seconds, that´s easy by dividing through 1000.

What I need is decimal place for the milliseconds. How do I get it?

4

3 回答 3

6
long seconds = timeInMillis/1000;
long milliseconds = timeInMillis%1000;

double timeInSeconds = ((double)seconds) + (((double)milliseconds)/1000.0);
于 2013-04-07T15:45:03.060 回答
1

您也可以使用TimeUnit。它具有处理此类转换的简洁方法。就像从毫秒到秒的转换一样,反之亦然。

于 2013-04-07T15:49:58.013 回答
0

好吧,我太傻了。

刚刚取了数据类型Double

于 2013-04-07T15:46:09.530 回答