How to deal with Microsoft date format in JSON /Date(1293753600000)/.

5
We are getting a JSON reponse with microsoft date format like "/Date(1293753600000)/". Does anyone know how to convert this to a normal datetime in Mendix 6.8.1?   Thanks!
asked
4 answers
3

Use substring to extract the numeric value and feed that to CommunityCommons.LongToDateTime

answered
2

I think your best option is to build a custom Java action to do this. I found something that might work, there were more people in the world with this same problem.

 

http://stackoverflow.com/questions/9127529/how-to-parse-net-datetime-received-as-json-string-into-javas-date-object

answered
1

The Stackoverflow article describe a date format of {"DateOfBirth":"\/Date(736032869080)\/"}. This combination of two characters “\/” is supported in the JSON structure window. It will be translate to {"DateOfBirth":"1993-04-28T21:34:29.0800000Z"} as a DateTime attribute. The use of a single “/” charter gives an error message in the JSON structure window.

answered
1

Hi Theo

 

This is an Epoch date - and I think I know exactly where you're getting it from ;)

 

I've solved the same issue in connecting to the same ERP as follows:

Create a string variable then do: replaceAll($Entity/Date,'[^0-9]','') 

This gets rid of everything except the date, then all you have to do is use the LongToDate java action from the community commons module to convert that to an actual useful date format.

answered