Skip to content
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

Core: Add DateFormatter interface for java time parsing (#33467) #33716

Merged
merged 2 commits into from
Sep 17, 2018

Conversation

spinscale
Copy link
Contributor

The existing approach used date formatters when a format based string
like date_time||epoch_millis was used, instead of the custom code.

In order to properly solve this, a new interface called
DateFormatter has been added, which now can be implemented for custom
formatters. Currently there are two implementations, one using java time
and one doing the epoch_millis formatter, which simply parses a number
and then converts it to a date in UTC timezone.

The DateFormatter interface now also has a method to retrieve the name
of the formatter pattern, which is needed for mapping changes anyway.

The existing CompoundDateTimeFormatter class has been removed, the
name was not really nice anyway.

One more minor change is the fact, that the new java time using
FormatDateFormatter does not try to parse the date with its printer
implementation first (which might be a strict one and fail), but a
printer can now be specified in addition. This saves one potential
failure/exception when parsing less strict dates.

If only a printer is specified, the printer will also be used as a
parser.

This is the 6.x backport of #33467

The existing approach used date formatters when a format based string
like `date_time||epoch_millis` was used, instead of the custom code.

In order to properly solve this, a new interface called
`DateFormatter` has been added, which now can be implemented for custom
formatters. Currently there are two implementations, one using java time
and one doing the epoch_millis formatter, which simply parses a number
and then converts it to a date in UTC timezone.

The DateFormatter interface now also has a method to retrieve the name
of the formatter pattern, which is needed for mapping changes anyway.

The existing `CompoundDateTimeFormatter` class has been removed, the
name was not really nice anyway.

One more minor change is the fact, that the new java time using
FormatDateFormatter does not try to parse the date with its printer
implementation first (which might be a strict one and fail), but a
printer can now be specified in addition. This saves one potential
failure/exception when parsing less strict dates.

If only a printer is specified, the printer will also be used as a
parser.
@spinscale spinscale added >non-issue :Core/Infra/Core Core issues without another label labels Sep 14, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@elasticdog
Copy link
Contributor

This job triggered CI during a migration of the master. Kicking off an additional build for you manually...

Jenkins, test this please.

@spinscale spinscale merged commit a17e0e8 into elastic:6.x Sep 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label >non-issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants