RED-8650 - Support more date formats

This commit is contained in:
Andrei Isvoran 2024-04-18 09:55:42 +03:00
parent 1af74c3f2e
commit dda8c98b87
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

@ -157,7 +157,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;
} }