From c211c68a46194b263adcb7147370b03faed8e975 Mon Sep 17 00:00:00 2001 From: lewa <lene.wasskog@nibio.no> Date: Fri, 13 Jan 2023 12:45:54 +0100 Subject: [PATCH] fix: Set correct decimal separator symbol Necessary in order to fix issues related to different locales at different machines. This was discovered when tests failed at one laptop and not another. --- .../no/nibio/model/maizepheno/MaizePhenologyModel.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/no/nibio/model/maizepheno/MaizePhenologyModel.java b/src/main/java/no/nibio/model/maizepheno/MaizePhenologyModel.java index 4a63ea2..c0b7c1b 100644 --- a/src/main/java/no/nibio/model/maizepheno/MaizePhenologyModel.java +++ b/src/main/java/no/nibio/model/maizepheno/MaizePhenologyModel.java @@ -20,6 +20,7 @@ package no.nibio.model.maizepheno; import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -28,6 +29,7 @@ import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.TimeZone; import java.util.stream.Collectors; @@ -84,7 +86,10 @@ public class MaizePhenologyModel extends I18nImpl implements Model{ Date lastDate = this.dataMatrix.getLastDateWithParameterValue(DataMatrix.TND); Double heatSum = 0.0; List<Result> retVal = new ArrayList<>(); - DecimalFormat dFormat = new DecimalFormat("###.##"); + + DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.getDefault()); + symbols.setDecimalSeparator('.'); + DecimalFormat dFormat = new DecimalFormat("###.##", symbols); while(!currentDate.after(lastDate)) { Result result = new ResultImpl(); -- GitLab