Issue
When an incorrect date format is used, it does not give an error, but outputs an incorrect date in Studio Pro v9 and below.
As seen below, the expression parseDateTime($DateString, 'yyyyMMdd') is used instead of parseDateTime($DateString, 'yyyy-MM-dd'), resulting in the date being parsed incorrectly.


Environment
Studio Pro v9 and below
Cause
The Mendix runtime follows the Java Specification. In Java, lenient parsing and strict parsing are terms used to describe how certain operations (especially in date/time parsing) handle input data that deviates from expected formats or constraints.
Lenient parsing is forgiving of minor errors or deviations in the input data and tries to adjust or normalize the data to fit the expected format.
Strict parsing enforces strict adherence to the input format or constraints and throws an error if the input does not match exactly.
Since parseDateTime uses Lenient parsing by default, the parser attempts to interpret the input reasonably instead of throwing an exception.
Solution/Workaround
To resolve this issue, a few approaches can be taken:
- Do the date parsing in a Java action and call
setLenient()onDateFormatto throw an error. - Use the isMatch function and a regular expression to check whether a string input is in the correct date-time format:
isMatch($DateString, '^\d{4}-\d{1,2}-\d{1,2}$') - Upgrade the project to at least Studio Pro v10.
Internal information related
- 169612, 170756
- DAT-3346
- C3T260XGA/p1667396208414239
Additional information
- Mendix documentation:
- Related KBA:
0 Comments