Skip to content

Commit c849d12

Browse files
committed
SONARJAVA-1185 Force locale to english to parse double and float literals
1 parent 0f61cc1 commit c849d12

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

java-checks/src/main/java/org/sonar/java/checks/MagicNumberCheck.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@
3838

3939
import java.math.BigDecimal;
4040
import java.text.DecimalFormat;
41+
import java.text.DecimalFormatSymbols;
4142
import java.text.ParseException;
43+
import java.util.Locale;
4244

4345
@Rule(
4446
key = "S109",
@@ -65,7 +67,9 @@ public void visitEnumConstant(EnumConstantTree tree) {
6567
@Override
6668
public void visitLiteral(LiteralTree tree) {
6769
if (isNumberLiteral(tree)) {
70+
6871
DecimalFormat decimalFormat = new DecimalFormat();
72+
decimalFormat.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.ENGLISH));
6973
decimalFormat.setParseBigDecimal(true);
7074
BigDecimal checked = null;
7175
try {

0 commit comments

Comments
 (0)