Date format acts weird

Hi everyone,   I'm having trouble with date format with Mendix... Date d = new Date(); String str = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.000").format(d); return str; I expect this code to return something like '2016-11-3T10:54:03.000' but it returns 3/11/2016. I've tried to run this exact same code on an online java tester and it returns me the date with the right format.   Does someone have an idea on how i could fix it ?
2 answers

No need for a java action, you can simply format the current date in the format you want directly in Mendix by using:


(Java allows you to insert letters into your formatted date string by enclosing them in single quotes, but since Mendix already uses single quotes for strings, that doesn't work. Therefore I have simply split it into two formatDateTime functions, not sure if there is a better way)


Pierre, what I think you have run into is a bug in the Mendix debugger where it will change strings that look like dates, and for some reason parse them and display them in a different format. I have seen this happening as well. If you change you Java code to something like

return "testString1678943436", does that show up in the debugger okay?


Also, please do not use variable names like 'd' or 'str'.