new GsonBuilder().setDateFormat("yyyy-MM-dd'T'HH:mm:ss").create()
Here are the tests I did, I tried to log a Date from the API response.
The API webservice is giving us 2022-07-23T12:15:00.000Z which means 12:15 in GMT+0 (UTC) or 14:15 in GMT+2 (my local date).
After being processed by Geometric Weather, here is the usual incorrect log:
2022-07-23 14:07:10.855 25348-25408/wangdaye.com.geometricweather D/GWMF: Sat Jul 23 12:15:00 GMT+02:00 2022
And here is the correct log if you change the line of code with new GsonBuilder().create():
2022-07-23 14:06:29.105 25207-25270/wangdaye.com.geometricweather D/GWMF: Sat Jul 23 14:15:00 GMT+02:00 2022
To sum up, the line of code you added is by-passing the timezone which results in interpreting the GMT+0 as the current timezone (GMT+2 in my case). When reading the date it will show the UTC date as being a locale date instead of a UTC one.
Could you check why this line of code was added and if it is still useful?
If it still is, would it be possible to only use it with the weather providers that use it, and not use it with OWM and MF?
Hi @WangDaYeeeeee, we have many issues with timezone in the OWM and MF providers.
After investigating a bit, I found that this line of code is responsible for the issues: https://github.com/WangDaYeeeeee/GeometricWeather/blob/master/app/src/main/java/wangdaye/com/geometricweather/common/di/RetrofitModule.java#L37=
Here are the tests I did, I tried to log a Date from the API response. The API webservice is giving us
2022-07-23T12:15:00.000Z
which means 12:15 in GMT+0 (UTC) or 14:15 in GMT+2 (my local date).After being processed by Geometric Weather, here is the usual incorrect log:
And here is the correct log if you change the line of code with
new GsonBuilder().create()
:To sum up, the line of code you added is by-passing the timezone which results in interpreting the GMT+0 as the current timezone (GMT+2 in my case). When reading the date it will show the UTC date as being a locale date instead of a UTC one.
Could you check why this line of code was added and if it is still useful? If it still is, would it be possible to only use it with the weather providers that use it, and not use it with OWM and MF?