RED-8650 - Support more date formats #379

Merged
andrei.isvoran.ext merged 1 commits from RED-8650 into master 2024-04-18 09:45:02 +02:00
4 changed files with 5 additions and 5 deletions

View File

@ -48,7 +48,7 @@ public class DateConverter {
public String convertDate(Date date, String resultFormat) {
DateFormat resultDateFormat = new SimpleDateFormat(resultFormat, Locale.ENGLISH);
DateFormat resultDateFormat = new SimpleDateFormat(resultFormat, Locale.UK);
return resultDateFormat.format(date);
}
@ -68,12 +68,12 @@ public class DateConverter {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(DateConverter.class.getResourceAsStream("/date_formats.txt"))))) {
String line;
while ((line = reader.readLine()) != null) {
builder.appendOptional(DateTimeFormatter.ofPattern(line.trim(), Locale.ENGLISH));
builder.appendOptional(DateTimeFormatter.ofPattern(line.trim(), Locale.UK));
}
} catch (IOException e) {
throw new RuntimeException("Error reading date format file: " + e.getMessage());
}
return builder.toFormatter().withResolverStyle(ResolverStyle.SMART).withLocale(Locale.ENGLISH);
return builder.toFormatter().withResolverStyle(ResolverStyle.SMART).withLocale(Locale.UK);
}

View File

@ -1,9 +1,9 @@
dd-MMM-yyyy
dd MMM yyyy
dd MMM yy
dd MM yyyy
dd MMMM yyyy
MMMM dd, yyyy
dd-MMM-yyyy
dd.MM.yyyy
yyyy/MM/dd
yyyy-MM-dd

View File

@ -157,7 +157,7 @@ public class DocumineFloraTest extends AbstractRedactionIntegrationTest {
String[] dateArray = dates.split(", ");
boolean allEqual = true;
for (String date : dateArray) {
if (!"10/01/2022".equals(date)) {
if (!"10/01/2022".equals(date) && !"08/09/2024".equals(date)) {
allEqual = false;
break;
}