fixing instantToDateFormatString

This commit is contained in:
Francesco Mangiacrapa 2022-09-27 16:59:59 +02:00
parent f5cc79ec1f
commit 88fcc4d707
2 changed files with 9 additions and 10 deletions

View File

@ -97,6 +97,7 @@
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
<scope>provided</scope>
</dependency>
<!-- LOGGER -->

View File

@ -724,23 +724,21 @@ public class ConvertToDataValueObjectModel {
if (instantString == null)
return null;
String time = instantString;
String time = instantString.trim();
DateTimeFormatter formatter = null;
try {
formatter = DateTimeFormatter.ofPattern(DATE_FORMAT + " " + TIME_FORMAT);
} catch (Exception e) {
LOG.warn("Parsing error: ", e);
}
try {
if (formatter != null) {
if(time.contains("T")) {
formatter = DateTimeFormatter.ofPattern(DATE_FORMAT + " " + TIME_FORMAT);
LocalDateTime instant = LocalDateTime.parse(time);
return formatter.format(instant);
}else {
formatter = DateTimeFormatter.ofPattern(DATE_FORMAT);
LocalDate instant = LocalDate.parse(time, formatter);
return formatter.format(instant);
}
} catch (Exception e) {
LOG.warn("Date format error: ", e);
e.printStackTrace();
}
return instantString;