Explorar o código

Core: Fix Java Time DateFormatter printers (#32592)

A bug in the test suite prevented to properly check that all date
formatters printed the date the same way like joda time does.

This fixes the test and thus also a fair share of formats, that
now use the strict parser for printing.
Alexander Reelsen %!s(int64=7) %!d(string=hai) anos
pai
achega
823d40e19b

+ 1 - 0
server/src/main/java/org/elasticsearch/common/time/CompoundDateTimeFormatter.java

@@ -70,4 +70,5 @@ public class CompoundDateTimeFormatter {
     public String format(TemporalAccessor accessor) {
         return printer.format(accessor);
     }
+
 }

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 379 - 511
server/src/main/java/org/elasticsearch/common/time/DateFormatters.java


+ 6 - 4
server/src/test/java/org/elasticsearch/common/joda/JavaJodaTimeDuellingTests.java

@@ -453,10 +453,12 @@ public class JavaJodaTimeDuellingTests extends ESTestCase {
     }
 
     private void assertSamePrinterOutput(String format, ZonedDateTime javaDate, DateTime jodaDate) {
-        assertThat(jodaDate.getMillis(), is(javaDate.toEpochSecond() * 1000));
-        String javaTimeOut = DateFormatters.forPattern("dateOptionalTime").format(javaDate);
-        String jodaTimeOut = Joda.forPattern("dateOptionalTime").printer().print(jodaDate);
-        assertThat(javaTimeOut, is(jodaTimeOut));
+        assertThat(jodaDate.getMillis(), is(javaDate.toInstant().toEpochMilli()));
+        String javaTimeOut = DateFormatters.forPattern(format).format(javaDate);
+        String jodaTimeOut = Joda.forPattern(format).printer().print(jodaDate);
+        String message = String.format(Locale.ROOT, "expected string representation to be equal for format [%s]: joda [%s], java [%s]",
+                format, jodaTimeOut, javaTimeOut);
+        assertThat(message, javaTimeOut, is(jodaTimeOut));
     }
 
     private void assertSameDate(String input, String format) {

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio