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.
経過秒数を時間:分:秒に変換したい。例えば
93599 秒から:
25:59:59
どうやってやるの?(注: 24h は 0h にラップしないでください)
ここではモジュラス演算子%が役立ちます。このようなものはうまくいくでしょう
%
public static void convertTime(int seconds) { int secs = seconds % 60; int mins = (seconds / 60) % 60; int hours = (seconds / 60) / 60; System.out.printf("%d:%d:%d", hours, mins, secs); }