What would you think about eating some more Apache Dogfood?
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
Then we could use:
Precision.round(PI, 3);
Chris
Am 14.02.18, 22:09 schrieb "Christofer Dutz" <[email protected]>:
Hi,
I’m currently working though some of the examples and encountered a problem:
Code like this:
nextValue = Double.valueOf(df.format(nextValue));
Seems to not work correctly in Germany as we have a “,” as decimal
separator and “.” as grouping character.
This results numbers like “10,3” being passed into Double.valueOf which
causes exceptions.
If I change it to this:
try {
nextValue = df.parse(df.format(nextValue)).doubleValue();
} catch (ParseException e) {
// Ignore ...
}
It seems to do what the original codes intention was.
What would be the cleanest way to solve this problem? I seem to be seeing
this pattern quite a lot and the try/catch solution sounds quite annoying with
all this try-catch handling.
Chris