Improved property date get.
This commit is contained in:
parent
a1b0c34645
commit
251d4ef761
1 changed files with 34 additions and 3 deletions
|
@ -321,16 +321,47 @@ public class PathPropertyList extends ArrayList<PathProperty> implements PathPro
|
|||
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("dd/MM/yyyy"));
|
||||
result = LocalDate.parse(value, DateTimeFormatter.ofPattern(pattern));
|
||||
}
|
||||
catch (DateTimeParseException exception)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
|
|
Loading…
Reference in a new issue