Skip to content

Commit c1228f7

Browse files
committed
Format the decimal according to the locale of the system
1 parent e1af710 commit c1228f7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

storage/inchi/src/main/java/org/openscience/cdk/inchi/JniInChIInputAdapter.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.sf.jniinchi.JniInchiException;
2828
import net.sf.jniinchi.JniInchiInput;
2929

30+
import java.text.DecimalFormat;
3031
import java.util.List;
3132
import java.util.StringTokenizer;
3233

@@ -91,7 +92,14 @@ private static String checkOptions(final String ops) throws JniInchiException {
9192
sbOptions.append(" ");
9293
}
9394
} else if (isTimeoutOptions(op)) {
94-
sbOptions.append(FLAG_CHAR).append(op);
95+
if (op.contains(".") || op.contains(",")) { // only reformat if we actually have a decimal
96+
// because the JNI-InChI library is expecting an platform number, format it as such
97+
Double time = Double.parseDouble(op.substring(1));
98+
DecimalFormat format = new DecimalFormat("#.##");
99+
sbOptions.append(FLAG_CHAR).append('W').append(format.format(time));
100+
} else {
101+
sbOptions.append(FLAG_CHAR).append(op);
102+
}
95103
hasUserSpecifiedTimeout = true;
96104
if (tok.hasMoreTokens()) {
97105
sbOptions.append(" ");

0 commit comments

Comments
 (0)