Formatting ISO-compliant date

0
Hi guys,   For a webservice we're calling we need to supply a datetime value as a String in a very specific ISO-complaint format: yyyy-MM-dd'T'HH:mm:ss.SSSZ However, I cannot seem to get this right with the formatDateTime function in Mendix. The user selects a date and time in an inputfield (which is of type DateTime) however the following expresion doesn't work, and causes the dateTimeFormat to revert to it's default formatDateTime($Entity/dateTime, 'yyyy-MM-dd''T''HH:mm:ss.SSSZ')   I've read a topic with the same issue and an answer from Jasper was marked as accepted, however I'm still struggling with this. This is the part of the webservice we need to send: "dateTime": "2017-01-05T00:00:00.000Z"   Any tips? Thanks!
asked
3 answers
4

You can use

formatDateTime($Entity/dateTime, 'yyyy-MM-dd') + 'T' + formatDateTime($Entity/dateTime, 'HH:mm:ss.SSS') + 'Z'
answered
0

Chris, Ronald,

 

Below is a modelshare of the flow I'm using. The DateTime variable is set in the 'Create String Variable' action. The result of the value after debugging, is shown below the modelshare

 

https://modelshare.mendix.com/models/ea279d19-64c2-417d-aaf3-e94cde507b73/storemeasurement

 

answered
0

Another option would be to change the wsdl of the consumed webservice.  Since the format matches the datetime format that mendix uses you could just fake that it is a datetime attribute while in reality it is a string. That way you would not have to do any conversion you just map your datetime attribute from your domainmodel.

answered