Improved property date get.

This commit is contained in:
Christian P. MOMON 2022-01-22 03:30:18 +01:00
parent a1b0c34645
commit 251d4ef761

View file

@ -322,14 +322,45 @@ public class PathPropertyList extends ArrayList<PathProperty> implements PathPro
}
else
{
try
String pattern;
if (value.matches("\\d{1,2}/\\d{1,2}/\\d{4}"))
{
result = LocalDate.parse(value, DateTimeFormatter.ofPattern("dd/MM/yyyy"));
pattern = "dd/MM/yyyy";
}
catch (DateTimeParseException exception)
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;
}
}
}
//