Date format in json for mobile backend

207 views Asked by At

I am using App42 for my mobile backend. I need to put date field in my JSON that I am saving and further do a query on it for date search. I am not able to find it in document. Can anybody please let me know what is the required date format to do this?

1

There are 1 answers

0
Akshay On

You are not mentioned that which SDK you are using. I am posting an Android sample code for date search in App42 json storage.

String yourDate = Util.getUTCFormattedTimestamp();
JSONObject jsonData = new JSONObject();
jsonData.put("name", "sachin");
jsonData.put("DOB", yourDate);

// Inserting json document.
Storage storageObj = storage.insertJSONDocument("dbName", "collectionName", jsonData);
System.out.println(storageObj);

// building query.
Query query = QueryBuilder.build("DOB", yourDate, Operator.EQUALS);

// find documents by query.
Storage result = storage.findDocumentsByQuery("dbName", "collectionName", query);
System.out.println(result);