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

DateTimeException occurred "yyyy-MM-dd HH: mm: ss" string is converted to Date [DATAES-953] #1527

Closed
spring-projects-issues opened this issue Oct 15, 2020 · 5 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Oct 15, 2020

zhouxin2333 opened DATAES-953 and commented

Here is entity field

!image-2020-10-15-19-44-45-701.png!

 Without any other configuration, I can write it to Elasticsearch, but I can't read. The following exception occurred

!image-2020-10-15-19-49-17-907.png!

The whole stack is in there: [^exception stack.txt]

 

By the way,  I think the problem is in 'ElasticsearchDateConverter.parse(String)'

!image-2020-10-15-19-54-58-421.png!

Instant can‘t use the result of  'dateFormatter.parse(input)' as a parameter to execute the from method. It should just like 'JavaDateFormatter.format' do.

!image-2020-10-15-19-57-43-121.png!

Convert TemporalAccessor to ZonedDateTime by 'DateFormatters.from' , and then Instant.from(ZonedDateTime).

'ElasticsearchDateConverter.parse(String)' is modified as follows

!image-2020-10-15-20-00-59-501.png!

The above is my opinion, I hope the problem can be solved. Thank you!


Affects: 4.0.4 (Neumann SR4), 4.1 RC2 (2020.0.0)

Attachments:

Referenced from: pull request #538

Backported to: 4.0.5 (Neumann SR5)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 15, 2020

sothawo commented

You should use "uuuu" instead of "yyyy" in your pattern. See the documentation at

https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.mapping.meta-model.annotations

, there in the info box

 

btw, why not use Instant from the java.time package?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 15, 2020

zhouxin2333 commented

Thanks for your comment. And I try the 'uuuu' instead, but it still doesn't work either. :(

!image-2020-10-15-23-02-07-035.png!

 

!image-2020-10-15-22-53-51-462.png!

Here is all stack [^exception stack_uuuu.txt]

 

I think the result of  'dateFormatter.parse(input)' must be converted to ZonedDateTime by 'DateFormatters.from' ;)

As for why not use Instant from the java.time package? This is historical reason.

Of course, if the format is changed to 'date_hour_minute_second', it work well and It's just that the time format stored in the database is slightly different. 

But the Date type seems to be a problem. So I want to confirm with you. 

 

 

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 15, 2020

zhouxin2333 commented

sothawo forget  @ you 

By the way, I change the field type Date to Instant, but it not work either.

!image-2020-10-15-23-12-46-126.png!

 

!image-2020-10-15-23-13-11-599.png!

 Here is the all stacks: [^exception stack_instant.txt]

 

 

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 15, 2020

sothawo commented

after changing the format to use uuuu, was the index mappings updated?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 15, 2020

sothawo commented

ok, can reproduce it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.