Skip to content

Commit

Permalink
[FIXED JENKINS-37329] Fixed DecimalFormat problem with VM language
Browse files Browse the repository at this point in the history
settings other than EN
  • Loading branch information
opx3 committed Aug 17, 2016
1 parent d7b6838 commit 20d0608
Showing 1 changed file with 5 additions and 2 deletions.
@@ -1,6 +1,8 @@
package jenkins.plugins.build_metrics.stats;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;

public class StatsMath {

Expand All @@ -9,7 +11,8 @@ public static double getPercent(double subVal, double totalVal){
}

public static double roundTwoDecimals(double iVal){
DecimalFormat twoDForm = new DecimalFormat("#.##");
return Double.valueOf(twoDForm.format(iVal));
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.getDefault());
DecimalFormat twoDForm = new DecimalFormat("#"+decimalFormatSymbols.getDecimalSeparator()+"##",decimalFormatSymbols);
return Double.valueOf(twoDForm.format(iVal));
}
}

0 comments on commit 20d0608

Please sign in to comment.