Created
May 6, 2013 17:42
-
-
Save jimmy087/5526714 to your computer and use it in GitHub Desktop.
Convert time into milliseconds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Exercise5_25 { | |
| public static void main(String[] args) { | |
| java.util.Scanner input = new java.util.Scanner(System.in); | |
| System.out.print("Please enter the amount of milliseconds to convert: "); | |
| long milliSeconds = input.nextLong(); | |
| System.out.println(milliSeconds + " milliseconds in hours, minutes and seconds is " + ((convertMillis(milliSeconds) / 3600) | |
| + " hours "+ ((convertMillis(milliSeconds) % 3600) / 60) + " minutes " + ((convertMillis(milliSeconds) % 3600) % 60) + " seconds.")); | |
| } | |
| private static long convertMillis(long milliSeconds) { | |
| long seconds = milliSeconds / 1000; | |
| return seconds; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment