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.
This commit is contained in:
parent
9b00f095b9
commit
823d40e19b
|
@ -70,4 +70,5 @@ public class CompoundDateTimeFormatter {
|
||||||
public String format(TemporalAccessor accessor) {
|
public String format(TemporalAccessor accessor) {
|
||||||
return printer.format(accessor);
|
return printer.format(accessor);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -453,10 +453,12 @@ public class JavaJodaTimeDuellingTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertSamePrinterOutput(String format, ZonedDateTime javaDate, DateTime jodaDate) {
|
private void assertSamePrinterOutput(String format, ZonedDateTime javaDate, DateTime jodaDate) {
|
||||||
assertThat(jodaDate.getMillis(), is(javaDate.toEpochSecond() * 1000));
|
assertThat(jodaDate.getMillis(), is(javaDate.toInstant().toEpochMilli()));
|
||||||
String javaTimeOut = DateFormatters.forPattern("dateOptionalTime").format(javaDate);
|
String javaTimeOut = DateFormatters.forPattern(format).format(javaDate);
|
||||||
String jodaTimeOut = Joda.forPattern("dateOptionalTime").printer().print(jodaDate);
|
String jodaTimeOut = Joda.forPattern(format).printer().print(jodaDate);
|
||||||
assertThat(javaTimeOut, is(jodaTimeOut));
|
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) {
|
private void assertSameDate(String input, String format) {
|
||||||
|
|
Loading…
Reference in New Issue