Fixed locale bug.
This commit is contained in:
parent
d410a7d029
commit
57c208e242
@ -21,6 +21,7 @@ package org.april.agirstatool.cli;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.BasicConfigurator;
|
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("{} AgirStatool call: {}", LocalDateTime.now(), new StringList(args).toStringSeparatedBy(" "));
|
||||||
|
|
||||||
// logger.info("Single connection opened with [{}].", this.url);
|
// logger.info("Single connection opened with [{}].", this.url);
|
||||||
|
@ -23,6 +23,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.math.NumberUtils;
|
import org.apache.commons.lang3.math.NumberUtils;
|
||||||
@ -43,8 +44,8 @@ public class AgirStatoolUtils
|
|||||||
{
|
{
|
||||||
private static Logger logger = LoggerFactory.getLogger(ProjectPage.class);
|
private static Logger logger = LoggerFactory.getLogger(ProjectPage.class);
|
||||||
|
|
||||||
public static final DateTimeFormatter PATTERN_SHORTDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy");
|
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'h'mm");
|
public static final DateTimeFormatter PATTERN_LONGDATE = DateTimeFormatter.ofPattern("dd/MM/yyyy hh':'mm", Locale.FRANCE);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalise week date.
|
* Normalise week date.
|
||||||
@ -89,14 +90,14 @@ public class AgirStatoolUtils
|
|||||||
|
|
||||||
LocalDate normalizedEnd = normaliseWeekDate(end);
|
LocalDate normalizedEnd = normaliseWeekDate(end);
|
||||||
LocalDate date = normaliseWeekDate(start);
|
LocalDate date = normaliseWeekDate(start);
|
||||||
int index = source.indexOf(start.format(DateTimeFormatter.ofPattern("yyyyww")));
|
int index = source.indexOf(toYearWeek(start));
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
{
|
{
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd))
|
while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd))
|
||||||
{
|
{
|
||||||
String dateToken = date.format(DateTimeFormatter.ofPattern("yyyyww"));
|
String dateToken = toYearWeek(date);
|
||||||
long count;
|
long count;
|
||||||
if (index < source.size())
|
if (index < source.size())
|
||||||
{
|
{
|
||||||
@ -145,7 +146,7 @@ public class AgirStatoolUtils
|
|||||||
long count = 0;
|
long count = 0;
|
||||||
while (date.isBefore(end) || date.isEqual(end))
|
while (date.isBefore(end) || date.isEqual(end))
|
||||||
{
|
{
|
||||||
String dateToken = date.format(DateTimeFormatter.ofPattern("yyyyww"));
|
String dateToken = toYearWeek(date);
|
||||||
DateCount current = source.get(dateToken);
|
DateCount current = source.get(dateToken);
|
||||||
if (current != null)
|
if (current != null)
|
||||||
{
|
{
|
||||||
@ -398,4 +399,28 @@ public class AgirStatoolUtils
|
|||||||
//
|
//
|
||||||
return result;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package org.april.agirstatool.core.pages;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.april.agirstatool.charts.DateCountList;
|
import org.april.agirstatool.charts.DateCountList;
|
||||||
@ -229,7 +230,7 @@ public class CreatedClosedCountChartView
|
|||||||
LocalDate date = AgirStatoolUtils.normaliseWeekDate(start);
|
LocalDate date = AgirStatoolUtils.normaliseWeekDate(start);
|
||||||
while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd))
|
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);
|
result.add(label);
|
||||||
date = date.plusWeeks(1);
|
date = date.plusWeeks(1);
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package org.april.agirstatool.core.pages;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
import org.april.agirstatool.charts.DateCount;
|
import org.april.agirstatool.charts.DateCount;
|
||||||
@ -214,7 +215,7 @@ public class CreatedClosedDiffChartView
|
|||||||
LocalDate date = AgirStatoolUtils.normaliseWeekDate(start);
|
LocalDate date = AgirStatoolUtils.normaliseWeekDate(start);
|
||||||
while (date.isBefore(normalizedEnd) || date.isEqual(normalizedEnd))
|
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);
|
result.add(label);
|
||||||
date = date.plusWeeks(1);
|
date = date.plusWeeks(1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user