spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.98k stars 40.65k forks source link

Different behavior of the @DateTimeFormat when running on Local env and on Cloud env (Heroku) #42430

Closed rayman245 closed 4 weeks ago

rayman245 commented 4 weeks ago

I noticed some inconsistency in the behavior of the @DateTimeFormat (DTF) annotation where passing the date "30-9-2024 7:41:00 pm" using @DateTimeFormat(pattern="d-M-yyyy h:mm:ss a") worked on my local but failed in cloud environment, and this was after upgrading the project from SB2 to SB3.3.3.

Tested out a few scenarios and below is my results:

image

image

not sure if could be related to https://github.com/spring-projects/spring-framework/issues/30649 ?

bclozel commented 4 weeks ago

This is a duplicate of https://github.com/spring-projects/spring-framework/issues/33151

sbrannen commented 3 days ago

Hi @rayman245,

For such issues, we are planning to suggest the use of fallback patterns that take a narrow non-breaking space (\u202F) into account.

In light of that, can you please confirm that the following addresses your issue?

@DateTimeFormat(pattern = "d-M-yyyy h:mm:ss a", fallbackPatterns = "d-M-yyyy h:mm:ss\u202Fa")

Thanks,

Sam