Skip to content

Commit

Permalink
better decimal number format
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Apr 16, 2020
1 parent a3b8b99 commit 05fd1c6
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.*;

Expand Down Expand Up @@ -346,13 +347,14 @@ public static String bigDecToString(BigDecimal input) {
}
return temp;
}
public static DecimalFormat df = new DecimalFormat("0", DecimalFormatSymbols.getInstance(Locale.ENGLISH));

static {
df.setMaximumFractionDigits(340);
}

public static String doubleToString(double input) {
String temp = String.valueOf(input);
if (temp.endsWith(".0")) {
return temp.substring(0, temp.length() - 2);
}
return temp;
return df.format(input);
}

/**
Expand Down

0 comments on commit 05fd1c6

Please sign in to comment.