From 8c33805d3727bde6982cc33c0e6c2de5a8c66c3e Mon Sep 17 00:00:00 2001 From: berndmoos Date: Sat, 11 May 2024 16:50:42 +0200 Subject: [PATCH] Forgot a bit from fix for #21 --- src/main/java/fr/noop/subtitle/vtt/VttParser.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/noop/subtitle/vtt/VttParser.java b/src/main/java/fr/noop/subtitle/vtt/VttParser.java index 57b4d54..27d273f 100644 --- a/src/main/java/fr/noop/subtitle/vtt/VttParser.java +++ b/src/main/java/fr/noop/subtitle/vtt/VttParser.java @@ -338,10 +338,14 @@ private List parseCueText(String cueText) { private SubtitleTimeCode parseTimeCode(String timeCodeString) throws SubtitleParsingException { try { - int hour = Integer.parseInt(timeCodeString.substring(0, 2)); - int minute = Integer.parseInt(timeCodeString.substring(3, 5)); - int second = Integer.parseInt(timeCodeString.substring(6, 8)); - int millisecond = Integer.parseInt(timeCodeString.substring(9, 12)); + String adjustedTimeCodeString = timeCodeString; + if (timeCodeString.length()<10){ + adjustedTimeCodeString = "00:" + timeCodeString; + } + int hour = Integer.parseInt(adjustedTimeCodeString.substring(0, 2)); + int minute = Integer.parseInt(adjustedTimeCodeString.substring(3, 5)); + int second = Integer.parseInt(adjustedTimeCodeString.substring(6, 8)); + int millisecond = Integer.parseInt(adjustedTimeCodeString.substring(9, 12)); return new SubtitleTimeCode(hour, minute, second, millisecond); } catch (NumberFormatException e) { throw new SubtitleParsingException(String.format(