parseDateTime($Date, yyyy-MM-ddTHH:mm:ss.SSSZ)

Hi everyone, i need to parse a datetime string in the following format: Format: ISO 8601; YYYY-MM-DDTHH:mm:ss.sssZ Example: 2015-07-04T12:08:56.235+01:00 parseDateTime($Date, 'YYYY-MM-DDTHH:mm:ss.SSSZ') this does not work in mendix because it will tell me that the T is not recognized. The idea was to change the pattern to "YYYY-MM-DD'T'HH:mm:ss.SSSZ" but the double quotes are not allowed either by mendix. Does anyone have an idea on how to do this date time conversion?
4 answers

You can parse dates that contain text, without having to replace or alter the text in any way.

The parse and format date expression have an option to literally use the text from the pattern. Simply place your text between two single quotes.

For example if I want to print the following text:      My Date: 07/28/2015 My Time: 10:20
I would use the following expression: 'My Date:' MM/dd/yyyy 'My Time:' HH:mm

As you can see I used a single quote around the text that isn't part of my pattern and that will be placed directly in the date.

If you'd like to use this in a microflow expression you'd have to do something extra. The single quote starts and ends a string. So if you would use the single quote in the expression it wouldn't work. Because it would start and end the string multiple times.

You'll need to escape the single quote. In a Mendix microflow a single quote is escaped by putting another single quote in front of it: '' (these are 2 single quotes ', not a double qoute ").

So my microflow expression would be: (please note these are all single quotes)

parseDateTime( '''My Date:'' MM/dd/yyyy ''My Time:'' HH:mm', $MyDate)

And to parse your date with the T in it you'd use:

parseDateTime( 'YYYY-MM-DD''T''HH:mm:ss.SSSZ', $MyDate)


Fixed it with 2 string adjustments, first replace the T

replaceFirst($DateString, 'T', ' ')

Then replace the Z part

replaceAll($DateString, '(+\d\d:\d\d)', '+' + replaceFirst( substring($DateString, length($DateString) -5, 5), ':', ''))

And then I can parse it

parseDateTime($DateString, 'yyyy-MM-dd HH:mm:ss.SSSZ')

Its not beautiful or elegant but it works


Did you try 'YYYY-MM-DD''T''HH:mm:ss.SSSZ' thus escaping the single quote that would normally end the string?


I ran in to the same issue. I looked in to this with my collegue and found the following solution.

In Java 8 some things changed for the datetime.

This format worked for me:

insert string:


then this worked:

parseDateTime($DateTimeString, 'yyyy-MM-dd''T''HH:mm:ss.SSSX')

Z is replaced with X in your example.