I think I have a similar problem to https://www.b4x.com/android/forum/threads/datetime-dateformat.116006/, but mine is not a server solution.
(short version)
Am I correct to think that because standard classes all run on the main thread (unlike server classes), that when any class instance sets DateTime.DateFormat the setting affects all other instances of that class also?
(longer version)
I have two subs in a standard class with code similar to:
With 6 instances of this class running, I am occassionally getting an Unparseable date error:
Is it possible that one class instance is setting the DateFormat in the first sub above while another instance is waiting for the database query in the second and then failing at the DateParse because of an incorrect DateFormat?
(short version)
Am I correct to think that because standard classes all run on the main thread (unlike server classes), that when any class instance sets DateTime.DateFormat the setting affects all other instances of that class also?
(longer version)
I have two subs in a standard class with code similar to:
B4X:
Private Sub a_Status (msg As String)
DateTime.DateFormat = "dd/MM/yyyy HH:mm:ss"
lblErrorMsg.Text=DateTime.Date(DateTime.Now) & ": " & msg
End Sub
B4X:
Private Sub getDatabaseDate
DateTime.DateFormat="yyyy-MM-dd HH:mm:ss"
Wait For (DB.QueryDate) Complete (mapDate as map)
Dim Success As Boolean = mapDate.Get("success")
If success Then
Dim d as string = mapDate.Get("date") 'will be in format "yyyy-MM-dd HH:mm:ss"
Dim longDate as Long = DateTime.DateParse(d)
log(longDate)
End If
End Sub
With 6 instances of this class running, I am occassionally getting an Unparseable date error:
B4X:
java.text.ParseException: Unparseable date: "2021-03-28 02:00:00"
Is it possible that one class instance is setting the DateFormat in the first sub above while another instance is waiting for the database query in the second and then failing at the DateParse because of an incorrect DateFormat?