New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed conversion of date field values when using multiple date formats #6266
Conversation
@@ -142,7 +142,7 @@ public static FormatDateTimeFormatter forPattern(String input, Locale locale) { | |||
} else { | |||
DateTimeFormatter dateTimeFormatter = null; | |||
for (int i = 0; i < formats.length; i++) { | |||
DateTimeFormatter currentFormatter = forPattern(formats[i], locale).parser(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why doesn't break this in the single format case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because this is code is in an if statement which checks for "||" in the format. The single format cases use a standard formatter which work for both printing and parsing. This code creates a formatter which uses all of the formats to parse a date but only the first format for printing a date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@colings86 Is it correct to use the printer to define how dates should be parsed, I would rather expect it to be the role of parsers? I think we need in this iteration to collect parsers for all inputs formats as well as the printer of the first one? (while master currently uses the first parser as a printer, and your patch collect all printers to know how to parse)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jpountz Yes you a probably right, I'll change it to store the parsers for all format and just the first printer
Closes #6239 |
LGTM |
+1 to push |
…le date formats When multiple date formats are specified using the || syntax in the field mappings the date_histogram aggregation breaks. This is because we are getting a parser rather than a printer from the date formatter for the object we use to convert the DateTime values back into Strings. Simple fix to get the printer from the date format and test to back it up Closes #6239
When multiple date formats are specified using the || syntax in the field mappings the date_histogram aggregation breaks. This is because we are getting a parser rather than a printer from the date formatter for the object we use to convert the DateTime values back into Strings. Simple fix to get the printer form the date format and test to back it up
Closes #6239