RED-8650 - Support more date formats #378

Merged
andrei.isvoran.ext merged 1 commits from RED-8650-bp into release/4.190.x 2024-04-18 09:45:05 +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) { 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); 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"))))) { try (BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(DateConverter.class.getResourceAsStream("/date_formats.txt"))))) {
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
builder.appendOptional(DateTimeFormatter.ofPattern(line.trim(), Locale.ENGLISH)); builder.appendOptional(DateTimeFormatter.ofPattern(line.trim(), Locale.UK));
} }
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException("Error reading date format file: " + e.getMessage()); 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 yyyy
dd MMM yy dd MMM yy
dd MM yyyy dd MM yyyy
dd MMMM yyyy dd MMMM yyyy
MMMM dd, yyyy MMMM dd, yyyy
dd-MMM-yyyy
dd.MM.yyyy dd.MM.yyyy
yyyy/MM/dd yyyy/MM/dd
yyyy-MM-dd yyyy-MM-dd

View File

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