Skip to content

Commit

Permalink
Fixed ColonTime format incorrectly parsing milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgeiss0702 committed Sep 23, 2023
1 parent 01d139f commit 3bf0960
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public class ColonTime extends Format {

private final Pattern pattern = Pattern.compile("(([0-9]*):)?([0-9]*):([0-9]*)(:|.)?([0-9]*)?");
private final Pattern pattern = Pattern.compile("(([0-9]*):)?([0-9][0-9]?):([0-9][0-9]?)((:|\\.)([0-9][0-9]?[0-9]?))?$");
@Override
public boolean matches(String output, String placeholder) {
if(output == null) return false;
Expand All @@ -30,8 +30,8 @@ public double toDouble(String input) throws NumberFormatException {
int minutes = Integer.parseInt(matcher.group(3));
int seconds = Integer.parseInt(matcher.group(4));

String secondSeparator = matcher.group(5);
String milliseconds = matcher.group(6);
String secondSeparator = matcher.group(6);
String milliseconds = matcher.group(7);

double result = 0;

Expand All @@ -47,6 +47,7 @@ public double toDouble(String input) throws NumberFormatException {
}
}

Debug.info(input + ": " + result);
return result;

}
Expand Down

0 comments on commit 3bf0960

Please sign in to comment.