Compare commits

..

No commits in common. "c98fc07e1bcd562775109096f5a767f77347cbba" and "a414ba7956e6b43c3199e577f7eb0d9058923fe9" have entirely different histories.

12 changed files with 134 additions and 707 deletions

View file

@ -21,9 +21,7 @@ package fr.devinsy.statoolinfos.core;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Year;
import org.apache.commons.lang3.StringUtils;
@ -386,23 +384,6 @@ public class Federation extends PathPropertyList
return result;
}
/**
* Gets the member organizations.
*
* @param year
* the year
* @return the member organizations
*/
public Organizations getMemberOrganizations(final Year year)
{
Organizations result;
result = this.organizations.filterMemberFor(year);
//
return result;
}
/**
* Gets the metric month values all.
*
@ -523,40 +504,6 @@ public class Federation extends PathPropertyList
return result;
}
/**
* Gets the service count by.
*
* @param year
* the year
* @return the service count by
*/
public long getServiceCountBy(final Year year)
{
long result;
Organizations organizations = this.organizations.filterMemberFor(year);
result = 0;
for (Organization organization : organizations)
{
for (Service service : organization.getServices().getBy(year))
{
Year memberStart = organization.getMemberStartYear();
Year memberEnd = organization.getMemberEndYear();
Year serviceStart = service.getStartYear();
Year serviceEnd = service.getEndYear();
if (StatoolInfosUtils.overlapp(memberStart, memberEnd, serviceStart, serviceEnd))
{
result += 1;
}
}
}
//
return result;
}
/**
* Gets the all services.
*
@ -631,22 +578,7 @@ public class Federation extends PathPropertyList
*
* @return the start date
*/
public LocalDate getStartDate()
{
LocalDate result;
result = StatoolInfosUtils.parseDate(getStartDateValue());
//
return result;
}
/**
* Gets the start date.
*
* @return the start date
*/
public String getStartDateValue()
public String getStartDate()
{
String result;
@ -656,29 +588,6 @@ public class Federation extends PathPropertyList
return result;
}
/**
* Gets the start year.
*
* @return the start year
*/
public Year getStartYear()
{
Year result;
LocalDate date = getStartDate();
if (date == null)
{
result = null;
}
else
{
result = Year.from(date);
}
//
return result;
}
/**
* Gets the technical doc website.
*

View file

@ -22,7 +22,6 @@ import java.io.File;
import java.net.URL;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Year;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
@ -149,7 +148,10 @@ public class Organization extends PathPropertyList
{
String result;
result = StatoolInfosUtils.toHumanDuration(getStartDate(), getEndDate());
LocalDate startDate = StatoolInfosUtils.parseDate(getStartDate());
LocalDate endDate = StatoolInfosUtils.parseDate(getEndDate());
result = StatoolInfosUtils.toHumanDuration(startDate, endDate);
//
return result;
@ -270,22 +272,7 @@ public class Organization extends PathPropertyList
*
* @return the end date
*/
public LocalDate getEndDate()
{
LocalDate result;
result = StatoolInfosUtils.parseDate(getEndDateValue());
//
return result;
}
/**
* Gets the end date.
*
* @return the end date
*/
public String getEndDateValue()
public String getEndDate()
{
String result;
@ -295,30 +282,6 @@ public class Organization extends PathPropertyList
return result;
}
/**
* Gets the end year.
*
* @return the end year
*/
public Year getEndYear()
{
Year result;
LocalDate date = getEndDate();
if (date == null)
{
result = null;
}
else
{
result = Year.from(date);
}
//
return result;
}
public Federation getFederation()
{
return this.federation;
@ -501,7 +464,10 @@ public class Organization extends PathPropertyList
{
String result;
result = StatoolInfosUtils.toHumanDuration(getMemberStartDate(), getMemberEndDate());
LocalDate startDate = StatoolInfosUtils.parseDate(getMemberStartDate());
LocalDate endDate = StatoolInfosUtils.parseDate(getMemberEndDate());
result = StatoolInfosUtils.toHumanDuration(startDate, endDate);
//
return result;
@ -512,39 +478,7 @@ public class Organization extends PathPropertyList
*
* @return the member end date
*/
public LocalDate getMemberEndDate()
{
LocalDate result;
result = getDate("organization.memberof." + this.federation.getName() + ".enddate");
//
return result;
}
/**
* Gets the member end date.
*
* @param entityName
* the entity name
* @return the member end date
*/
public LocalDate getMemberEndDate(final String entityName)
{
LocalDate result;
result = getDate("organization.memberof." + entityName + ".enddate");
//
return result;
}
/**
* Gets the member end date.
*
* @return the member end date
*/
public String getMemberEndDateValue()
public String getMemberEndDate()
{
String result;
@ -554,67 +488,12 @@ public class Organization extends PathPropertyList
return result;
}
/**
* Gets the member end year.
*
* @return the member end year
*/
public Year getMemberEndYear()
{
Year result;
LocalDate date = getMemberEndDate();
if (date == null)
{
result = null;
}
else
{
result = Year.from(date);
}
//
return result;
}
/**
* Gets the member start date.
*
* @return the member start date
*/
public LocalDate getMemberStartDate()
{
LocalDate result;
result = getDate("organization.memberof." + this.federation.getName() + ".startdate");
//
return result;
}
/**
* Gets the member start date.
*
* @param entityName
* the entity name
* @return the member start date
*/
public LocalDate getMemberStartDate(final String entityName)
{
LocalDate result;
result = getDate("organization.memberof." + entityName + ".startdate");
//
return result;
}
/**
* Gets the member start date.
*
* @return the member start date
*/
public String getMemberStartDateValue()
public String getMemberStartDate()
{
String result;
@ -624,29 +503,6 @@ public class Organization extends PathPropertyList
return result;
}
/**
* Gets the member start year.
*
* @return the member start year
*/
public Year getMemberStartYear()
{
Year result;
LocalDate date = getMemberStartDate();
if (date == null)
{
result = null;
}
else
{
result = Year.from(date);
}
//
return result;
}
/**
* Gets the status member of.
*
@ -887,22 +743,7 @@ public class Organization extends PathPropertyList
*
* @return the start date
*/
public LocalDate getStartDate()
{
LocalDate result;
result = StatoolInfosUtils.parseDate(getStartDateValue());
//
return result;
}
/**
* Gets the start date.
*
* @return the start date
*/
public String getStartDateValue()
public String getStartDate()
{
String result;
@ -912,30 +753,6 @@ public class Organization extends PathPropertyList
return result;
}
/**
* Gets the start year.
*
* @return the start year
*/
public Year getStartYear()
{
Year result;
LocalDate date = getStartDate();
if (date == null)
{
result = null;
}
else
{
result = Year.from(date);
}
//
return result;
}
/**
* Gets the status.
*
@ -1295,7 +1112,7 @@ public class Organization extends PathPropertyList
{
boolean result;
if ((getServiceCount() == 0) && (getLogoURLValue() == null) && (getStartDateValue() == null))
if ((getServiceCount() == 0) && (getLogoURLValue() == null) && (getStartDate() == null))
{
result = true;
}
@ -1331,51 +1148,6 @@ public class Organization extends PathPropertyList
return result;
}
/**
* Checks if is member.
*
* @param year
* the year
* @return true, if is member
*/
public boolean isMember(final Year year)
{
boolean result;
if (year == null)
{
result = false;
}
else
{
Year startYear = getMemberStartYear();
if (startYear == null)
{
result = false;
}
else
{
Year endYear = getMemberEndYear();
if (endYear == null)
{
endYear = Year.now();
}
if ((year.isBefore(startYear)) || (year.isAfter(endYear)))
{
result = false;
}
else
{
result = true;
}
}
}
//
return result;
}
/**
* Checks if is valid.
*

View file

@ -18,7 +18,6 @@
*/
package fr.devinsy.statoolinfos.core;
import java.time.Year;
import java.util.ArrayList;
import java.util.Collections;
@ -183,31 +182,6 @@ public class Organizations extends ArrayList<Organization>
return result;
}
/**
* Filter member for.
*
* @param year
* the year
* @return the organizations
*/
public Organizations filterMemberFor(final Year year)
{
Organizations result;
result = new Organizations();
for (Organization organization : this)
{
if (organization.isMember(year))
{
result.add(organization);
}
}
//
return result;
}
/**
* Gets the active service count.
*

View file

@ -22,7 +22,6 @@ import java.io.File;
import java.net.URL;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Year;
import java.time.YearMonth;
import org.apache.commons.codec.digest.DigestUtils;
@ -137,7 +136,10 @@ public class Service extends PathPropertyList
{
String result;
result = StatoolInfosUtils.toHumanDuration(getStartDate(), getEndDate());
LocalDate startDate = StatoolInfosUtils.parseDate(getStartDate());
LocalDate endDate = StatoolInfosUtils.parseDate(getEndDate());
result = StatoolInfosUtils.toHumanDuration(startDate, endDate);
//
return result;
@ -248,22 +250,7 @@ public class Service extends PathPropertyList
*
* @return the end date
*/
public LocalDate getEndDate()
{
LocalDate result;
result = StatoolInfosUtils.parseDate(getEndDateValue());
//
return result;
}
/**
* Gets the end date value.
*
* @return the end date value
*/
public String getEndDateValue()
public String getEndDate()
{
String result;
@ -273,30 +260,6 @@ public class Service extends PathPropertyList
return result;
}
/**
* Gets the end year.
*
* @return the end year
*/
public Year getEndYear()
{
Year result;
LocalDate date = getEndDate();
if (date == null)
{
result = null;
}
else
{
result = Year.from(date);
}
//
return result;
}
/**
* Gets the host name.
*
@ -888,22 +851,7 @@ public class Service extends PathPropertyList
*
* @return the start date
*/
public LocalDate getStartDate()
{
LocalDate result;
result = StatoolInfosUtils.parseDate(getStartDateValue());
//
return result;
}
/**
* Gets the start date value.
*
* @return the start date value
*/
public String getStartDateValue()
public String getStartDate()
{
String result;
@ -913,30 +861,6 @@ public class Service extends PathPropertyList
return result;
}
/**
* Gets the start year.
*
* @return the start year
*/
public Year getStartYear()
{
Year result;
LocalDate date = getStartDate();
if (date == null)
{
result = null;
}
else
{
result = Year.from(date);
}
//
return result;
}
/**
* Gets the status.
*
@ -1132,7 +1056,7 @@ public class Service extends PathPropertyList
{
boolean result;
if (getEndDateValue() == null)
if (getEndDate() == null)
{
result = false;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -18,8 +18,6 @@
*/
package fr.devinsy.statoolinfos.core;
import java.time.LocalDate;
import java.time.Year;
import java.util.ArrayList;
import java.util.Collections;
@ -42,42 +40,6 @@ public class Services extends ArrayList<Service>
super();
}
/**
* Count by year.
*
* @param year
* the year
* @return the long
*/
public long countBy(final Year year)
{
long result;
result = 0;
Year now = Year.now();
for (Service service : this)
{
Year start = service.getStartYear();
Year end = service.getEndYear();
if (start != null)
{
if (end == null)
{
end = now;
}
if ((!start.isAfter(year) && (!end.isBefore(year))))
{
result += 1;
}
}
}
//
return result;
}
/**
* Gets the by.
*
@ -155,95 +117,6 @@ public class Services extends ArrayList<Service>
return result;
}
/**
* Gets the by.
*
* @param year
* the year
* @return the by
*/
public Services getBy(final Year year)
{
Services result;
result = new Services();
if (year != null)
{
for (Service service : this)
{
Year startYear = service.getStartYear();
Year endYear = service.getEndYear();
if (endYear == null)
{
endYear = Year.now();
}
if ((startYear != null) && (!year.isBefore(startYear)) && (!year.isAfter(endYear)))
{
result.add(service);
}
}
}
//
return result;
}
/**
* Gets the older.
*
* @return the older
*/
public Service getOldestService()
{
Service result;
result = null;
LocalDate oldestDate = null;
for (Service current : this)
{
LocalDate date = current.getStartDate();
if (date != null)
{
LocalDate currentDate = current.getStartDate();
if ((result == null) || (currentDate.isBefore(oldestDate)))
{
result = current;
oldestDate = currentDate;
}
}
}
//
return result;
}
/**
* Gets the oldest year.
*
* @return the oldest year
*/
public Year getOldestStartYear()
{
Year result;
Service oldestService = getOldestService();
if (oldestService == null)
{
result = null;
}
else
{
result = oldestService.getStartYear();
}
//
return result;
}
/**
* Reverse.
*

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -27,7 +27,6 @@ import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.Year;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
@ -207,63 +206,6 @@ public class StatoolInfosUtils
return new Date().getTime();
}
/**
* Overlapp.
*
* @param start1
* the start 1
* @param end1
* the end 1
* @param start2
* the start 2
* @param end2
* the end 2
* @return true, if successful
*/
public static boolean overlapp(final Year start1, final Year end1, final Year start2, final Year end2)
{
boolean result;
if ((start1 == null) || (start2 == null))
{
result = false;
}
else
{
Year end11;
if (end1 == null)
{
end11 = Year.now();
}
else
{
end11 = end1;
}
Year end22;
if (end2 == null)
{
end22 = Year.now();
}
else
{
end22 = end2;
}
if ((end22.isBefore(start1)) || (start2.isAfter(end11)))
{
result = false;
}
else
{
result = true;
}
}
//
return result;
}
/**
* Parses the date.
*
@ -293,10 +235,6 @@ public class StatoolInfosUtils
{
result = LocalDate.parse("01/" + date, DateTimeFormatter.ofPattern("dd/MM/yyyy"));
}
else if (date.matches("\\d{4}-\\d{2}"))
{
result = LocalDate.parse(date + "-01", DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
else
{
result = null;

View file

@ -38,6 +38,7 @@ import fr.devinsy.statoolinfos.core.Organizations;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.Services;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.htmlize.charts.BarChart;
import fr.devinsy.statoolinfos.htmlize.charts.BarChartView;
import fr.devinsy.statoolinfos.htmlize.charts.ChartColor;
@ -1266,7 +1267,8 @@ public class ChartHtmlizer
{
String result;
result = htmlizeServiceCountMonthChart(federation.getServicesAll(), YearMonth.from(federation.getStartDate()));
result = htmlizeServiceCountMonthChart(federation.getServicesAll(),
YearMonth.from(StatoolInfosUtils.parseDate(federation.getStartDate())));
//
return result;
@ -1285,7 +1287,7 @@ public class ChartHtmlizer
{
String result;
LocalDate startDate = organization.getFederation().getStartDate();
LocalDate startDate = StatoolInfosUtils.parseDate(organization.getFederation().getStartDate());
if (startDate == null)
{
@ -1316,7 +1318,7 @@ public class ChartHtmlizer
YearMonth first = null;
for (Service service : services)
{
LocalDate date = service.getStartDate();
LocalDate date = StatoolInfosUtils.parseDate(service.getStartDate());
if (date != null)
{
YearMonth current = YearMonth.from(date);
@ -1360,8 +1362,8 @@ public class ChartHtmlizer
long count = 0;
for (Service service : services)
{
LocalDate startDate = service.getStartDate();
LocalDate endDate = service.getEndDate();
LocalDate startDate = StatoolInfosUtils.parseDate(service.getStartDate());
LocalDate endDate = StatoolInfosUtils.parseDate(service.getEndDate());
if (startDate != null)
{
@ -1451,23 +1453,7 @@ public class ChartHtmlizer
{
String result;
BarChart chart;
chart = new BarChart("Nombre de services");
chart.addDataset("Services");
Year current = federation.getStartYear();
Year now = Year.now();
while (!current.isAfter(now))
{
long count = federation.getServiceCountBy(current);
chart.add(String.valueOf(current), count, ChartColor.YELLOW);
current = current.plusYears(1);
}
result = BarChartView.build(chart);
result = htmlizeServiceCountYearChart(federation.getServices(), StatoolInfosUtils.parseDate(federation.getStartDate()).getYear());
//
return result;
@ -1486,7 +1472,16 @@ public class ChartHtmlizer
{
String result;
result = htmlizeServiceCountYearChart(organization.getServices(), organization.getFederation().getStartYear());
LocalDate startDate = StatoolInfosUtils.parseDate(organization.getFederation().getStartDate());
if (startDate == null)
{
result = null;
}
else
{
result = htmlizeServiceCountYearChart(organization.getServices(), startDate.getYear());
}
//
return result;
@ -1508,7 +1503,7 @@ public class ChartHtmlizer
Integer first = null;
for (Service service : services)
{
LocalDate date = service.getStartDate();
LocalDate date = StatoolInfosUtils.parseDate(service.getStartDate());
if (date != null)
{
int current = date.getYear();
@ -1547,11 +1542,36 @@ public class ChartHtmlizer
if (first != null)
{
int now = Year.now().getValue();
int now = LocalDate.now().getYear();
int current = first;
while (current <= now)
{
long count = services.countBy(Year.of(current));
long count = 0;
for (Service service : services)
{
LocalDate startDate = StatoolInfosUtils.parseDate(service.getStartDate());
LocalDate endDate = StatoolInfosUtils.parseDate(service.getEndDate());
if (startDate != null)
{
int start = startDate.getYear();
int end;
if (endDate == null)
{
end = now;
}
else
{
end = endDate.getYear();
}
if ((current >= start) && (current <= end))
{
count += 1;
}
}
}
chart.add(String.valueOf(current), count, ChartColor.YELLOW);
current += 1;
@ -1564,37 +1584,6 @@ public class ChartHtmlizer
return result;
}
/**
* Htmlize service count year chart.
*
* @param services
* the services
* @param first
* the first
* @return the string
* @throws StatoolInfosException
* the statool infos exception
*/
public static String htmlizeServiceCountYearChart(final Services services, final Year first) throws StatoolInfosException
{
String result;
Integer value;
if (first == null)
{
value = null;
}
else
{
value = first.getValue();
}
result = htmlizeServiceCountYearChart(services, value);
//
return result;
}
/**
* Htmlize service date status chart.
*
@ -1614,7 +1603,7 @@ public class ChartHtmlizer
long unfilled = 0;
for (Service service : services)
{
if (service.getStartDate() == null)
if (StatoolInfosUtils.parseDate(service.getStartDate()) == null)
{
unfilled += 1;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -69,7 +69,7 @@ public class FederationHeaderView
data.setEscapedContent("federationURL", federation.getWebsiteURL().toString());
data.setEscapedAttribute("federationURL", "href", federation.getWebsiteURL().toString());
}
data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDateValue(), "n/a"));
data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDate(), "n/a"));
data.setAttribute("organizationsLink", "href", federation.getTechnicalName() + "-organizations.xhtml");
data.setAttribute("servicesLink", "href", federation.getTechnicalName() + "-services.xhtml");

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2022 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -71,10 +71,10 @@ public class OrganizationHeaderView
data.setEscapedContent("organizationDescription", organization.get("organization.description"));
data.setEscapedContent("organizationMemberOfName", StringUtils.defaultIfBlank(organization.getFederation().getName(), "n/a"));
data.setContent("organizationStartDate", StringUtils.defaultIfBlank(organization.getStartDateValue(), "n/a"));
data.setContent("organizationEndDate", StringUtils.defaultIfBlank(organization.getEndDateValue(), "n/a"));
data.setContent("organizationStartDate", StringUtils.defaultIfBlank(organization.getStartDate(), "n/a"));
data.setContent("organizationEndDate", StringUtils.defaultIfBlank(organization.getEndDate(), "n/a"));
data.setContent("organizationAge", StringUtils.defaultIfBlank(organization.getAge(), "n/a"));
if (StringUtils.isBlank(organization.getEndDateValue()))
if (StringUtils.isBlank(organization.getEndDate()))
{
data.setContent("organizationMemberOfWord", "depuis");
data.setAttribute("organizationEndDateData", "style", "display: none;");
@ -84,10 +84,10 @@ public class OrganizationHeaderView
data.setContent("organizationMemberOfWord", ":");
}
data.setContent("organizationMemberStartDate", StringUtils.defaultIfBlank(organization.getMemberStartDateValue(), "n/a"));
data.setContent("organizationMemberEndDate", StringUtils.defaultIfBlank(organization.getMemberEndDateValue(), "n/a"));
data.setContent("organizationMemberStartDate", StringUtils.defaultIfBlank(organization.getMemberStartDate(), "n/a"));
data.setContent("organizationMemberEndDate", StringUtils.defaultIfBlank(organization.getMemberEndDate(), "n/a"));
data.setContent("organizationMemberAge", StringUtils.defaultIfBlank(organization.getMemberAge(), "n/a"));
if (StringUtils.isBlank(organization.getMemberEndDateValue()))
if (StringUtils.isBlank(organization.getMemberEndDate()))
{
data.setAttribute("organizationMemberEndDateData", "style", "display: none;");
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -69,10 +69,10 @@ public class ServiceHeaderView
data.setEscapedContent("serviceDescription", StringUtils.defaultIfBlank(service.getDescription(), "n/a"));
data.setContent("serviceStartDate", StringUtils.defaultIfBlank(service.getStartDateValue(), "n/a"));
data.setContent("serviceEndDate", StringUtils.defaultIfBlank(service.getEndDateValue(), "n/a"));
data.setContent("serviceStartDate", StringUtils.defaultIfBlank(service.getStartDate(), "n/a"));
data.setContent("serviceEndDate", StringUtils.defaultIfBlank(service.getEndDate(), "n/a"));
data.setContent("serviceAge", StringUtils.defaultIfBlank(service.getAge(), "n/a"));
if (StringUtils.isBlank(service.getEndDateValue()))
if (StringUtils.isBlank(service.getEndDate()))
{
data.setAttribute("serviceEndDateData", "style", "display: none;");
}

View file

@ -24,6 +24,8 @@ import java.net.URL;
import java.time.LocalDate;
import java.time.Year;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.regex.Matcher;
@ -313,7 +315,53 @@ public class PathPropertyList extends ArrayList<PathProperty> implements PathPro
{
LocalDate result;
result = StatoolInfosUtils.parseDate(get(path));
String value = get(path);
if (value == null)
{
result = null;
}
else
{
String pattern;
if (value.matches("\\d{1,2}/\\d{1,2}/\\d{4}"))
{
pattern = "dd/MM/yyyy";
}
else if (value.matches("\\d{4}-\\d{2}-\\d{2}"))
{
pattern = "yyyy-MM-dd";
}
else if (value.matches("\\d{1,2}/\\d{4}"))
{
value = "01/" + value;
pattern = "dd/MM/yyyy";
}
else if (value.matches("\\d{4}-\\d{2}"))
{
value = value + "-01";
pattern = "yyyy-MM-dd";
}
else
{
pattern = null;
}
if (pattern == null)
{
result = null;
}
else
{
try
{
result = LocalDate.parse(value, DateTimeFormatter.ofPattern(pattern));
}
catch (DateTimeParseException exception)
{
result = null;
}
}
}
//
return result;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -507,7 +507,7 @@ public class StatAgent
//
for (Organization organization : organizations)
{
if (StringUtils.isBlank(organization.getStartDateValue()))
if (StringUtils.isBlank(organization.getStartDate()))
{
result.incPassiveCount();
}