public class Test {
private static final int SECOND_PER_HOUR = 60 * 60;
private static final int SECOND_PER_MINUTE = 60;
public static void main(String[] args) {
long second = new Scanner(System.in).nextLong();
long hour = second / SECOND_PER_HOUR;
second -= SECOND_PER_HOUR * hour;
int minute = (int) (second / SECOND_PER_MINUTE);
second -= SECOND_PER_MINUTE * minute;
System.out.println(String.format("%d小时%d分钟%d秒", hour, minute, second));
}
}
按单位,转换就是了
~
~
~~~~~~~~~~~~~~~~~~~