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

CXF-9054 do not use Date and SimpleDateFormat when parsing LocalDate,… #2056

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vershnik
Copy link
Contributor

@vershnik vershnik commented Sep 9, 2024

… use the appropriate DateTimeFormatter for LocalDate

@reta
Copy link
Member

reta commented Sep 9, 2024

Thanks @vershnik , as you pointed out, this is very likely JDK related issue [1] that is not related to CXF (and impact all other applications out there).

[1] https://bugs.openjdk.org/browse/JDK-8294357

@vershnik
Copy link
Contributor Author

Even though it may turn out to be JDK issue, I think using DateTimeFormatter for parsing LocalDate is more appropriate and performance efficient (no need to create instances of SimpleDateFormat, Date, Instant, ZonedDateTime)

@reta
Copy link
Member

reta commented Sep 11, 2024

Even though it may turn out to be JDK issue, I think using DateTimeFormatter for parsing LocalDate is more appropriate and performance efficient (no need to create instances of SimpleDateFormat, Date, Instant, ZonedDateTime)

The DateTimeFormatter is certainly newer API than SimpleDateFormat but to my knowledge, DateTimeFormatter and SimpleDateFormat are not compatible [1], [2] (please correct me if I am wrong here). We could bring the changes than risk to break existing applications but those won't be backported.

To your point, it would make sense to migrate to java.time APIs but that should not be limited to LocalDate only (for example, the SearchUtils still use SimpleDateFormat).

[1] https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
[2] https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html

@vershnik
Copy link
Contributor Author

yes, looks like there is incompatibility between DateTimeFormatter and SimpleDateFormat
For example SimpleDateFormat for pattern 'yyyy-MM-dd' can parse even dates that contain time:
parse("2019-07-07 23:59:59")

while DateTimeFormatter is more strict here. So this change cannot be backported.

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

Successfully merging this pull request may close these issues.

2 participants