diff --git a/api/src/main/java/ca/bc/gov/educ/api/distribution/util/GradLocalDateTimeDeserializer.java b/api/src/main/java/ca/bc/gov/educ/api/distribution/util/GradLocalDateTimeDeserializer.java index ebd75d6a..812956cb 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/distribution/util/GradLocalDateTimeDeserializer.java +++ b/api/src/main/java/ca/bc/gov/educ/api/distribution/util/GradLocalDateTimeDeserializer.java @@ -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); }