edgent-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christofer Dutz <christofer.d...@c-ware.de>
Subject Re: Problem running some examples with non US locales
Date Wed, 14 Feb 2018 21:13:28 GMT
What would you think about eating some more Apache Dogfood?


Then we could use: 

Precision.round(PI, 3);


Am 14.02.18, 22:09 schrieb "Christofer Dutz" <christofer.dutz@c-ware.de>:

    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.

View raw message