Android Question datetime conversion issues

RichyK68

Active Member
Licensed User
Longtime User
I've run into a problem with an app of mine since daylight saving came into effect overnight. I've done a few tests and the following code gives weird results:

B4X:
Dim test1 As String = "17:10"
test1 = DateTime.Time(DateTime.TimeParse(test1))
Dim test2 As String = "00:00"
test2 = DateTime.Time(DateTime.TimeParse(test2))

Test1 now contains "17:10" and Test2 now contains "23:00".

Why does Test2 contain "23:00" when it should contain "00:00" ?

Why aren't they either both wrong or both right?

Thanks,

Richard
 

RichyK68

Active Member
Licensed User
Longtime User
Oh and I'm already setting the format with

B4X:
DateTime.TimeFormat = "HH:mm"

so I don't understand why the time comes out wrong.
 
Upvote 0

RichyK68

Active Member
Licensed User
Longtime User
I haven't tried anything since midday yesterday (I spent a few hours pulling my hair out with this one). I've just set my LG G2's timezone to GMT +0 and Test2 comes back with "00:00" which is now correct. I've then reset the G2 settings back to what they were to use network provided time/time zone and ran the test again, and Test2 comes back with "00:00". So I'm guessing there's probably a bug in the G2 with daylight savings change-over, or perhaps the condition only affects my device for the first 24 hours after change-over. I don't know, but my app is now behaving as it should. I won't know again until daylight saving ends, unfortunately.
 
Upvote 0

RichyK68

Active Member
Licensed User
Longtime User
One year later, daylight saving comes in to effect, and I'm having the very same issue. Must be a G2 issue. Here's hoping that the problem goes away tomorrow like it did last year.
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
Maybe the reason:
Normally the DST changes between 2:00AM and 3:00AM. Therefore on the DST change day 17:10 is in the new DST zone and 00:00 may converted to the old DST zone?
 
Upvote 0
Top