Support Article
Date format in edit mode is not configured in Pega 7.1.9
Summary
The pxDateTime control does not provide a parameter to control the date format in edit mode.
Error Messages
Not Applicable.
Steps to Reproduce
Include a Date-Time control with Date-Time property. With no configuration to set the format of Date-time in edit mode.
Root Cause
Normally, the date-time format in edit mode depends on the operator locale or the system locale if the operator's locale is empty.
User's requirement is to have a parameter to control the date-time format in edit mode.
Resolution
Perform the following local-change:
1) Disable client-side validation on the harness which has the date-time control.
2) In the Scripts & styles of the Harness rule, add a js file with below content.
function formatDateUsingCustomLocale(ev){
if(ev && ev.target && ev.target.getAttribute("data-display-value")){
ev.target.value = ev.target.getAttribute("data-display-value");
}
}
function setCalLocale() {
pega.u.d.CalendarUtil.Locale.SHORT_DATE_TIME_FORMAT = "yyyy/MM/d h:mm a";
}
pega.util.Event.addListener(window, "load", setCalLocale, "", true);
3) For the date-time control in the actions tab
4) The edit-input to be configured for the date-time property with the below sample java code.
/*
Input -> 2016/04/21 10:24 AM
Output -> 21/04/2016 10:24 AM
*/
if(theValue.length()>0 && theValue.indexOf("/") > 2){
String Date = theValue.split(" ")[0],
Time = theValue.substring(theValue.indexOf(" "));
String[] myDate = Date.split("/");
theValue = myDate[2]+"/"+myDate[1]+"/"+myDate[0];
theValue = theValue + Time;
}
Published May 4, 2016 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.