Skip to content

Commit

Permalink
Fixed ColonTime format removing 0s from decimals
Browse files Browse the repository at this point in the history
  • Loading branch information
ajgeiss0702 committed Aug 15, 2023
1 parent c01a474 commit 269a7f8
Showing 1 changed file with 3 additions and 3 deletions.
Expand Up @@ -31,17 +31,17 @@ public double toDouble(String input) throws NumberFormatException {
int seconds = Integer.parseInt(matcher.group(4));

String secondSeparator = matcher.group(5);
int milliseconds = matcher.group(6) != null ? Integer.parseInt(matcher.group(6)) : -1;
String milliseconds = matcher.group(6);

double result = 0;

result += seconds;
result += minutes * 60;
result += hours * 60 * 60;

if(secondSeparator != null && milliseconds != -1) {
if(secondSeparator != null && milliseconds != null) {
if(secondSeparator.equals(":")) {
result += milliseconds / 1000d;
result += Integer.parseInt(milliseconds) / 1000d;
} else if(secondSeparator.equals(".")) {
result += Double.parseDouble("0." + milliseconds);
}
Expand Down

0 comments on commit 269a7f8

Please sign in to comment.