Android Question DateTime conversion - Difference between long date and string date?

Q Candiani

Member
Licensed User
Longtime User
Hi everyone. I'm working with B4A DateTime library. I am a little confused about the conversion from a long date to a string date using DateTime.

I use this code to convert the current date in a specific string format date:
B4X:
        Dim date_up As Long = DateTime.Now
        DateTime.DateFormat = "yyyy/MM/dd"
        DateTime.TimeFormat = "HH:mm:ss"
        Dim str_date_up As String = DateTime.Date(date_up) & " " & DateTime.Time(date_up)
        Return str_date_up

But, always I receive a string date with on hour less. For example:
In my country, it is 22:50 on October 20, 2018, UTC-03:00. DateTime.Now function returns 1540086655409. When I convert to string format, with the function previously shown, it returns 2018/10/20 21:50:55.
Why? Is it a time zone issue? I never define a timezone in my app. I assume the device default timezone. It's wrong?
 
Top