refactor split time parsing

This commit is contained in:
Christian Schabesberger 2018-09-09 14:01:39 +02:00
parent 49b72cbe5d
commit 8a4afe2548
1 changed files with 6 additions and 10 deletions

View File

@ -31,20 +31,16 @@ public class YoutubeParsingHelper {
public static long parseDurationString(String input) public static long parseDurationString(String input)
throws ParsingException, NumberFormatException { throws ParsingException, NumberFormatException {
String[] splitInput;
// If time separator : is not detected, try . instead // If time separator : is not detected, try . instead
if (input.contains(":")) { final String[] splitInput = input.contains(":")
splitInput = input.split(":"); ? input.split(":")
} else { : input.split("\\.");
splitInput = input.split("\\.");
}
String days = "0"; String days = "0";
String hours = "0"; String hours = "0";
String minutes = "0"; String minutes = "0";
String seconds; final String seconds;
switch (splitInput.length) { switch (splitInput.length) {
case 4: case 4: