I tried to use the code below, but I get the date = 01/17/1970 in all dates.
Where I am going wrong?
How to fix to display the date of the file?
Thanks for any tips to correct and improve the code.
B4X:
Sub Activity_Create(FirstTime As Boolean)
Dim job1 As HttpJob
job1.Initialize("Job1", Me)
'Send a GET request
job1.Download("http://snapshots.basic4android.de/imagedates.php")
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Dim res As String
res = Job.GetString
Dim parser As JSONParser
parser.Initialize(res)
Select Job.JobName
Case "Job1"
Dim ListOfAttributes As List
Dim FileName As String
Dim FileDate As Long
ListOfAttributes = parser.NextArray 'returns a list with maps
For i = 0 To 5
Dim MyFiles As Map
MyFiles = ListOfAttributes.Get(i)
FileName = MyFiles.Get("filename")
FileDate = MyFiles.Get("mtime")
Log(FileName & " - " & " - " & DateTime.Date(FileDate)) 'date = 01/17/1970
Next
End Select
Else
Log("Error: " & Job.ErrorMessage)
ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub