cxf icon indicating copy to clipboard operation
cxf copied to clipboard

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

Open vershnik opened this issue 1 year ago • 4 comments

… use the appropriate DateTimeFormatter for LocalDate

vershnik avatar Sep 09 '24 18:09 vershnik

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

reta avatar Sep 09 '24 21:09 reta

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)

vershnik avatar Sep 10 '24 05:09 vershnik

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

reta avatar Sep 11 '24 18:09 reta

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.

vershnik avatar Sep 17 '24 11:09 vershnik