In: Computer Science
Time String to Seconds
Write a method that takes a string representation of time in hours:minutes:seconds and returns the total number of seconds
For example, if the input is “0:02:20” it would return 140
If the input string is missing the hours component it should still work
For example, input of “10:45” would return 645
Write an overloaded form of the method that takes in only hours and minutes and returns the total number of seconds
It should leverage the first method you wrote
For example, an input of “2:05” should return 7205
Lastly, write a method that takes seconds and returns a well-formatted time string, e.g., with two digits in each place
For example, an input of 3666 would return “01:01:06”