-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMilliSeconds.java
More file actions
32 lines (21 loc) · 776 Bytes
/
Copy pathMilliSeconds.java
File metadata and controls
32 lines (21 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.Scanner;
public class MilliSeconds{
public static void main(String... args){
Scanner input = new Scanner(System.in);
System.out.print("Enter the Milli Seconds: ");
long milliSeconds = input.nextLong();
milliSeconds(milliSeconds);
}
public static String milliSeconds(long milliSeconds){
long secondsPerHour = 3600;
long minutesPerHour = 60;
long secondsPerMinute = 60;
long totalSeconds = milliSeconds / 1000;
long hours = totalSeconds / secondsPerHour;
long minutes = (totalSeconds % secondsPerHour) / minutesPerHour;
long seconds = totalSeconds % secondsPerMinute;
String timeString = String.format("%02d:%02d:%02d", hours, minutes, seconds);
System.out.println(timeString);
return timeString;
}
}