Tweak number format
All checks were successful
ci/woodpecker/manual/woodpecker Pipeline was successful

This commit is contained in:
Johannes Frohnmeyer 2023-01-20 18:15:03 +01:00
parent 3d398cc0b2
commit 4512d8741d
Signed by: Johannes
GPG Key ID: E76429612C2929F4

View File

@ -7,10 +7,9 @@ public class StringFormatter {
public static String toString(Object o) {
if (o == null) return "null";
else if (o instanceof Double d) {
if (d % 1.0 != 0)
return String.format(Locale.US, "%s", d);
else
return String.format(Locale.US, "%.0f", d);
if (d % 1.0 == 0) return String.format(Locale.US, "%.0f", d);
else if (d > 1) return String.format(Locale.US, "%.4f", d);
else return String.format(Locale.US, "%s", d);
} else if (o instanceof Throwable t) {
try {
return t.getMessage() + getStackTrace(t);