In my android app, I have a model with an attribut Date(). But when aI create this model, the date is creating with -2u. I have tried to resolve this with a method to change the time zone from GMT to UTC.
private fun getCurrentUTC(): Date { val calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")) return calendar.time }
and I call this method in my attribut date in the model
var date: Date = getCurrentUTC()
So, my front sends the bad date but in my backend (spring boot java), it receives the good date but it save
date before save in db : Sun Jun 02 17:33:14 CEST 2024 after save in db : Sun Jun 02 17:33:14 CEST 2024
in my db with the bad date (-2hours). I don’t ubnderstand what’s happend.
and it’s return the object with the dab date
"date":"2024-06-02T15:33:14.356+00:00",
I have searched in stackoverflow and what Itried it was wrong.
Fateha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.