forked from javamllama/build-metrics-plugin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Revert "[JENKINS-37329] - Changed caluclation of RoundDecimal again."
This reverts commit f22fe98.
- Loading branch information
Showing
2 changed files
with
7 additions
and
2 deletions.
There are no files selected for viewing
8 changes: 7 additions & 1 deletion
8
src/main/java/jenkins/plugins/build_metrics/stats/StatsMath.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
package jenkins.plugins.build_metrics.stats; | ||
|
||
import java.text.DecimalFormat; | ||
import java.text.DecimalFormatSymbols; | ||
import java.util.Locale; | ||
|
||
public class StatsMath { | ||
|
||
public static double getPercent(double subVal, double totalVal){ | ||
return roundTwoDecimals((totalVal == 0) ? 0.00 : (subVal / totalVal) * 100.00); | ||
} | ||
|
||
public static double roundTwoDecimals(double iVal){ | ||
return (double)Math.round(iVal * 100) / 100; | ||
DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols(Locale.getDefault()); | ||
DecimalFormat twoDForm = new DecimalFormat("#"+decimalFormatSymbols.getDecimalSeparator()+"##",decimalFormatSymbols); | ||
return Double.valueOf(twoDForm.format(iVal)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters