Improved property date get.
This commit is contained in:
parent
a1b0c34645
commit
251d4ef761
1 changed files with 34 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Loading…
Reference in a new issue