Android Question How to Convert Returned Json date to normal dd/mm/yyyy

Status
Not open for further replies.

Makumbi

Well-Known Member
Licensed User
Please help me how can i convert this json date to my normal date

B4X:
Dates: /Date(1542834000000)/

B4X:
Dim CustID As String = 782911364' Customer ID
    Dim j As HttpJob
    j.Initialize("", Me)
    'j.Download("http://192.168.1.239/WebServicesula/Service.asmx/Get")
    j.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVBPay.ashx?customerid=" & CustID)
    'j.Download("http://192.168.1.239/Generic_Handler_JSON/HandlerVB.ashx")
    'j.PostString("http://192.168.1.239/Webandroid//VB.aspx?customerid=" & CustID)
    
    j.GetRequest.Timeout = 10000 ' 10 seconds
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then ' if job is success (http status code 200)
        Dim RetVal As String
        RetVal = j.GetString
        
        Dim jp As JSONParser
        jp.Initialize(j.GetString)
        Log(jp) ' will pr
        Dim quotes As List = jp.NextArray
        For Each quot As Map In quotes
            Log("Customerid: " & quot.Get("Account"))
            Log("Name: " & quot.Get("Names"))
            Log("Class: " & quot.Get("Class"))
            Log("Stream: " & quot.Get("stream"))
            Log("Amount: " & quot.Get("Amount"))
            Log("Dates: " & quot.Get("Dates"))
            Log("Years: " & quot.Get("Years"))
            Log("Term: " & quot.Get("Term"))
        Next
    End If
 

Makumbi

Well-Known Member
Licensed User
l
What is the output of Log(jp) ?
it show this
[{"CustomerId":"05-00001","Name":"Makumbi Sulaiman","Stream":"N","Amount":45000,"Dates":"\/Date(1542834000000)\/","Term":"Term1 ","Years":"2018","Class":"S2"},{"CustomerId":"05-00002","Name":"Nkabirwa Rayan","Stream":"S","Amount":5000,"Dates":"\/Date(1542574800000)\/","Term":"Term1 ","Years":"2018","Class":"P4"}]
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
IMO, "JSON date" is a string according ISO 8601.2004 standard. For example, 2018-11-21T09:27:09.501Z.
My app communicates with server, which generates similar data using standard Javascript function.

I have no idea about B4a built-in functions which are able to convert this to ticks.
So, I used Substring and DateUtils.SetDate2
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
Ple
IMO, "JSON date" is a string according ISO 8601.2004 standard. For example, 2018-11-21T09:27:09.501Z.
My app communicates with server, which generates similar data using standard Javascript function.

I have no idea about B4a built-in functions which are able to convert this to ticks.
So, I used Substring and DateUtils.SetDate2
Please show me how you did it using my example
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
how can check if a table has data in it like checking the first row only please help i was using this but it does not bring out what i want
B4X:
cursor1 = Starter.SQL1.ExecQuery("SELECT id FROM student")
    'cursor1 = SQL1.ExecQuery("SELECT Phone FROM Register")
    If cursor1.RowCount > 0 Then
        For i = 0 To cursor1.RowCount - 1
            cursor1.Position = i
                
           Next

    End If
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
B4X:
cursor1 = Starter.SQL1.ExecQuery("SELECT id FROM student LIMIT 1")
    If cursor1.RowCount > 0 Then
            cursor1.Position = 0
            'do stuff
    else
              log("no records")
    End If
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
It only shows the data from the first record in the query regardless of how many records you have in the table
thanks how can i concatenate this message
B4X:
cursor1 = Starter.SQL1.ExecQuery("SELECT ID ,phone FROM Register")
        If cursor1.RowCount > 0 Then
            Msgbox("You are Already Registered" & cursor1.Getstring("Phone") &" ,"SMIS")

i what my message to show the Phone number of the person that is already registered in the message
example You are Already Registered with 0783333455
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
i what my message to show the Phone number of the person that is already registered
B4X:
Dim MyID As String ="0783333455"
    cursor1 = Starter.SQL1.ExecQuery2("SELECT ID , phone FROM Register WHERE ID = ?", Array As String(MyID))
    If cursor1.RowCount > 0 Then
        cursor1.Position=0
        MsgboxAsync("You are Already Registered with phone: " & cursor1.Getstring("Phone") ,"SMIS")
    Else
        Log("No such member in the database.")
    End If
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
B4X:
Dim MyID As String ="0783333455"
    cursor1 = Starter.SQL1.ExecQuery2("SELECT ID , phone FROM Register WHERE ID = ?", Array As String(MyID))
    If cursor1.RowCount > 0 Then
        cursor1.Position=0
        MsgboxAsync("You are Already Registered with phone: " & cursor1.Getstring("Phone") ,"SMIS")
    Else
        Log("No such member in the database.")
    End If
i f i had a big hen i would send it to your country but a i have a smile only thanks man
 
Upvote 0
Status
Not open for further replies.
Top