formatDateTime problem with seconds

I'm having a problem which I've been staring at for about an hour or so. I can't explain what is happening here. I use this expression formatDateTime([%CurrentDateTime%], 'yyyy-MM-dd''T''HH:mm:Z') which results in: 2017-09-05T16:57:+0200   Then I tried this one formatDateTime([%CurrentDateTime%], 'yyyy-MM-dd''T''HH:mm:sZ') which results in: 2017-09-05T17:22:9+0200   Last one I tried (and the one I actually need :) ) is: formatDateTime([%CurrentDateTime%], 'yyyy-MM-dd''T''HH:mm:ssZ') which results in this: 09/05/2017 17:24:39   And I can't explain the difference. Except that in the second case the format might be invalid and it reverts to a default. But I don't think the format is invalid, so I'm guessing a bug? 
3 answers

Hi Philip,

As far as I know Mendix uses Java SimpleDateFormat to format and parse dates -

Perhaps you can find answers by searching for your problem on StackOverflow or other non-mendix specific forums.

Hope this helps,




As Andrej said, Mendix does use Java formats for date time.

I took your last example and tested them out in 7.6.  In addition, in case the embedded T was causing some issues, I tried a variant that isolates the T as a separate string.  The results are shown below from a message box:

Is this what you need to end up with?  If so, I am not sure why your example yields the result that it does.  Anyway, maybe breaking it up a bit will help you troubleshoot what's happening.



I found the problem. The modeler (actually the debugger) is confusing me here. I tried with this:

formatDateTime(dateTime(2017,9,15,13,10,3), 'yyyy-MM-dd''T''HH:mm:ssZ')

The debugger shows me this:

But then when I look at the Soap XML that was generated ( I'm calling a microflow in the mapping):


And this what I want :)