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?
long seconds = timeInMillis/1000;
long milliseconds = timeInMillis%1000;
double timeInSeconds = ((double)seconds) + (((double)milliseconds)/1000.0);
您也可以使用TimeUnit。它具有处理此类转换的简洁方法。就像从毫秒到秒的转换一样,反之亦然。
好吧,我太傻了。
刚刚取了数据类型Double
。