Scenario
The following exceptions occur when using the toDate function after updating to Java Standard Edition (SE) version 11.
Exception stack trace 1
java.lang.IllegalArgumentException: Illegal pattern character 't'
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:845) ~[?:?]
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:653) ~[?:?]
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:624) ~[?:?]
Exception stack trace 2
"stacktrace":"java.lang.IllegalArgumentException: ClientDeviceId cannot be null\n\tat com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)\n\tat com.pega.pegarules.exec.external.basic.UserSpecializationsDTO.<init>(UserSpecializationsDTO.java:24)\n\tat com.pega.pegarules.session.internal.mgmt.SpecializationsCommandBuilder.addCommand(SpecializationsCommandBuilder.java:29)\n\tat com.pega.pegarules.session.internal.mgmt.PRRequestorImpl.setSpecializations(PRRequestorImpl.java:638)\n\tat com.pega.pegarules.session.internal.mgmt.PRThreadBase.setSpecializations(PRThreadBase.java:553)\n\tat com.pega.pegarules.session.internal.mgmt.PRThreadImpl.setSpecializations(PRThreadImpl.java:1223)\n\tat com.pega.pegarules.session.internal.engineinterface.service.HttpAPI.initializeLocaleAndUserAgents(HttpAPI.java:2525)\n\tat com.pega.pegarules.session.internal.engineinterface.service.HttpAPI.setThreadData(HttpAPI.java:6975)\n\tat com.pega.pegarules.session.external.engineinterface.service.EngineAPI.processRequestInner(EngineAPI.java:442)\n\tat jdk.internal.reflect.GeneratedMethodAccessor226.invoke(Unknown Source)\n\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)\n\tat
Environments
This issue was reported in the following environments:
- Pega Platform 8.7.5
- Pega Platform 8.8.3
- Pega Platform 24.1.1
Explanation
The Illegal pattern character 't' exception occurs on invoking a When Rule that calls the toDate method with an incorrect input parameter pattern (YYYY-MM-DD).
The ClientDeviceId cannot be null exception occurs because Pega only supports the en_GB format for the input parameter in the toDate method, and not the en-GB format. The incorrect en_#G input parameter in the en-GB format causes the exception.
Workaround
Update the input pattern of the toDate method from (YYYY-MM-DD) to toDate(DD-MM-YYYY).