1

我创建了计时器。如何将计时器格式更改为,以免它是长数字?谢谢

private long startTime  = System.currentTimeMillis();
Timer timer  = new Timer(1000, this);
timer.start();

timer.stop();
long endTime    = System.currentTimeMillis();
long timeInMilliseconds = (endTime - startTime);
4

2 回答 2

6

从毫秒除以 1000 秒。

于 2009-03-22T17:17:42.603 回答
0

您可以定义一个常量 SECOND 并像这样使用它:

new Timer(1 * SECOND, this);
于 2009-03-22T17:45:57.467 回答