ZonedDateTime parse issue
When I pass this to my endpoint:
for this entity:
in my database as a result I get: 2024-03-11 09:00:00.000 for date.
It should be 2024-03-11 09:00:00+03:00 - isn't this covered by @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ssXXX")
13 Replies
⌛
This post has been reserved for your question.
Hey @the goat! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Databases don't store time zone info. How could the database possibly contain something like +03:00?
should I store it as a string or I should ignore the timezone in the database
You should configure the database to use UTC as the time zone so that you know what time zone it uses. Then you should expect everything you read in it to be in UTC
can I do that in Spring
I am sorry if my question is stupid
I am just a bit lost
No, Spring doesn't operate databases. Database operators do
That's not a ZonedDateTime
That's an OffsetDateTime
ZonedDateTimes have timezones, this is an offset (
+03:00
)Offsets are representable as time zones, so essentially OffsetDateTimes are a subset of ZonedDateTimes
I can have an offset that says +3:45
What timezone would that be?
You can turn a timezone and a local datetime into an offset yes
Not the other way around though
Dude, try first, tell others they're wrong after.
It will be time zone +3:45 as far as ZonedDateTime is concerned
OK that's gross
So it seems an OffsetDateTime has a LocalDateTime and a ZoneOffset, and a ZonedDateTime has the same things but ALSO a ZoneId
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.