diff --git a/src/org/april/agirstatool/cli/AgirStatoolCLI.java b/src/org/april/agirstatool/cli/AgirStatoolCLI.java index cd723ab..077e600 100644 --- a/src/org/april/agirstatool/cli/AgirStatoolCLI.java +++ b/src/org/april/agirstatool/cli/AgirStatoolCLI.java @@ -21,6 +21,7 @@ package org.april.agirstatool.cli; import java.io.File; import java.sql.Connection; import java.time.LocalDateTime; +import java.util.Locale; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.BasicConfigurator; @@ -128,6 +129,9 @@ public final class AgirStatoolCLI } }); + // Set the locale to France is required for week alignment. + Locale.setDefault(Locale.FRANCE); + logger.info("{} AgirStatool call: {}", LocalDateTime.now(), new StringList(args).toStringSeparatedBy(" ")); // logger.info("Single connection opened with [{}].", this.url); diff --git a/src/org/april/agirstatool/core/AgirStatoolUtils.java b/src/org/april/agirstatool/core/AgirStatoolUtils.java index 3cd4598..074bf89 100644 --- a/src/org/april/agirstatool/core/AgirStatoolUtils.java +++ b/src/org/april/agirstatool/core/AgirStatoolUtils.java @@ -23,6 +23,7 @@ import java.time.LocalDateTime; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import java.util.Date; +import java.util.Locale; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; @@ -43,8 +44,8 @@ public class AgirStatoolUtils { private static Logger logger = LoggerFactory.getLogger(ProjectPage.class); - public static final DateTimeFormatter PATTERN_SHORTDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy"); - public static final DateTimeFormatter PATTERN_LONGDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy hh'h'mm"); + public static final DateTimeFormatter PATTERN_SHORTDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy", Locale.FRANCE); + public static final DateTimeFormatter PATTERN_LONGDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy hh':'mm", Locale.FRANCE); /** * Normalise week date. @@ -89,14 +90,14 @@ public class AgirStatoolUtils LocalDate normalizedEnd = normaliseWeekDate(end); LocalDate date = normaliseWeekDate(start); - int index = source.indexOf(start.format(DateTimeFormatter.ofPattern("yyyyww"))); + int index = source.indexOf(toYearWeek(start)); if (index == -1) { index = 0; } while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) { - String dateToken = date.format(DateTimeFormatter.ofPattern("yyyyww")); + String dateToken = toYearWeek(date); long count; if (index < source.size()) { @@ -145,7 +146,7 @@ public class AgirStatoolUtils long count = 0; while (date.isBefore(end) || date.isEqual(end)) { - String dateToken = date.format(DateTimeFormatter.ofPattern("yyyyww")); + String dateToken = toYearWeek(date); DateCount current = source.get(dateToken); if (current != null) { @@ -398,4 +399,28 @@ public class AgirStatoolUtils // return result; } + + /** + * To year week. + * + * @param source + * the source + * @return the string + */ + public static String toYearWeek(final LocalDate source) + { + String result; + + if (source == null) + { + result = null; + } + else + { + result = source.format(DateTimeFormatter.ofPattern("yyyyww", Locale.FRANCE)); + } + + // + return result; + } } diff --git a/src/org/april/agirstatool/core/pages/CreatedClosedCountChartView.java b/src/org/april/agirstatool/core/pages/CreatedClosedCountChartView.java index 805310d..ead493c 100644 --- a/src/org/april/agirstatool/core/pages/CreatedClosedCountChartView.java +++ b/src/org/april/agirstatool/core/pages/CreatedClosedCountChartView.java @@ -21,6 +21,7 @@ package org.april.agirstatool.core.pages; import java.io.IOException; import java.time.LocalDate; import java.time.format.DateTimeFormatter; +import java.util.Locale; import org.apache.commons.codec.digest.DigestUtils; import org.april.agirstatool.charts.DateCountList; @@ -229,7 +230,7 @@ public class CreatedClosedCountChartView LocalDate date = AgirStatoolUtils.normaliseWeekDate(start); while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) { - String label = date.format(DateTimeFormatter.ofPattern("yyyy-MMM")); + String label = date.format(DateTimeFormatter.ofPattern("yyyy-MMM", Locale.FRANCE)); result.add(label); date = date.plusWeeks(1); } diff --git a/src/org/april/agirstatool/core/pages/CreatedClosedDiffChartView.java b/src/org/april/agirstatool/core/pages/CreatedClosedDiffChartView.java index 87190c6..5ade9b8 100644 --- a/src/org/april/agirstatool/core/pages/CreatedClosedDiffChartView.java +++ b/src/org/april/agirstatool/core/pages/CreatedClosedDiffChartView.java @@ -21,6 +21,7 @@ package org.april.agirstatool.core.pages; import java.io.IOException; import java.time.LocalDate; import java.time.format.DateTimeFormatter; +import java.util.Locale; import org.apache.commons.codec.digest.DigestUtils; import org.april.agirstatool.charts.DateCount; @@ -214,7 +215,7 @@ public class CreatedClosedDiffChartView LocalDate date = AgirStatoolUtils.normaliseWeekDate(start); while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd)) { - String label = date.format(DateTimeFormatter.ofPattern("yyyy-MMM")); + String label = date.format(DateTimeFormatter.ofPattern("yyyy-MMM", Locale.FRANCE)); result.add(label); date = date.plusWeeks(1); }