On this date and other dates, but randomly, in the sense that sometimes there are no errors on the same dates
I use this code:
B4X:
Sub GetExifDateTime (Fpath As String, Fname As String) As Long
Dim temp As String
Dim ExifDate As Long
Dim exif As ExifData
exif.Initialize(Fpath, Fname)
temp = exif.getAttribute(exif.TAG_DATETIME)
DateTime.DateFormat = "yyyy:MM:dd HH:mm:ss"
ExifDate = DateTime.DateParse(temp)
Return ExifDate
End Sub
'In starter Service:
Sub Service_Create
Dim jo As JavaObject
jo.InitializeStatic("java.util.Locale").RunMethod("setDefault", Array(jo.GetField("US")))
End Sub
Hi, the problem wasn't the spaces - if you try this code you will see that it works.
B4X:
Sub Button1_Click
Dim temp As String
Dim ExifDate As Long
Try
temp = "2020: 09: 20 12:50:50"
DateTime.DateFormat= "yyyy:MM:dd HH:mm:ss"
ExifDate = DateTime.DateParse(temp)
Log (ExifDate)
xui.MsgboxAsync("OK:" & ExifDate, "B4X")
Catch
Log(LastException.Message)
xui.MsgboxAsync("Wrong Date:", "B4X")
End Try
End Sub
The problem was probably a service of mine running that was performing the same operation at the same time (DateTime.DateParse). Stopped the service the problem was solved.