Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我创建了计时器。如何将计时器格式更改为秒,以免它是长数字?谢谢
private long startTime = System.currentTimeMillis(); Timer timer = new Timer(1000, this); timer.start(); timer.stop(); long endTime = System.currentTimeMillis(); long timeInMilliseconds = (endTime - startTime);
从毫秒除以 1000 秒。
您可以定义一个常量 SECOND 并像这样使用它:
new Timer(1 * SECOND, this);