Skip to content

Commit

Permalink
Fix Date format when T present
Browse files Browse the repository at this point in the history
  • Loading branch information
arybakov-cgi committed Jul 25, 2023
1 parent ae1bcc7 commit b31a98e
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,18 @@ public LocalDateTime deserialize(JsonParser jsonParser, DeserializationContext d
formatter = DateTimeFormatter.ofPattern(SECOND_DEFAULT_DATE_FORMAT);
LocalDate localDate = LocalDate.parse(dateAsString, formatter);
return localDate.atStartOfDay();
} else if(StringUtils.isNotBlank(dateAsString) && dateAsString.length() > 10 && dateAsString.contains("/") && dateAsString.contains(" ")) {
} else if(StringUtils.isNotBlank(dateAsString) && dateAsString.length() > 10 && dateAsString.length() <= 19 && dateAsString.contains("/") && dateAsString.contains(" ")) {
formatter = DateTimeFormatter.ofPattern(SECOND_DEFAULT_DATE_TIME_FORMAT);
return LocalDateTime.parse(dateAsString, formatter);
} else if(StringUtils.isNotBlank(dateAsString) && dateAsString.length() > 10 && dateAsString.contains("-") && dateAsString.contains(" ")) {
} else if(StringUtils.isNotBlank(dateAsString) && dateAsString.length() > 10 && dateAsString.length() <= 19 && dateAsString.contains("-") && dateAsString.contains(" ")) {
formatter = DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT);
return LocalDateTime.parse(dateAsString, formatter);
} else if(StringUtils.isNotBlank(dateAsString) && dateAsString.length() > 19 && dateAsString.contains("/") && dateAsString.contains("T")) {
formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss.000+00:00");
return LocalDateTime.parse(StringUtils.replace(dateAsString, "T", " "), formatter);
} else if(StringUtils.isNotBlank(dateAsString) && dateAsString.length() > 19 && dateAsString.contains("-") && dateAsString.contains("T")) {
formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.000+00:00");
return LocalDateTime.parse(StringUtils.replace(dateAsString, "T", " "), formatter);
} else if(StringUtils.isNotBlank(dateAsString)) {
return LocalDateTime.parse(dateAsString, formatter);
}
Expand Down

0 comments on commit b31a98e

Please sign in to comment.