Hello,
I have a function that takes a date and changes it to the required format as String. If the date is null, it returns an empty string. However when i set the empty string returned by the function in my dateTime datatype property, the value is being set to 1970-01-01. (This is done in a data transform).
Also on the control Field that I am displaying the property it is of type date time also and i have added a personalized
format dd/MM/yyyy hh:mm:ss.
Can someone help please?
Thank you
Hi @User16730164, after your function execution, to your data transform add a when rule which will check if the return string is null, when true use “Remove” operation to remove your date time property from the clipboard.
@User16730164 the question has been raised on the forum before. See Date getting updated in DB table to 1970 even when the date is not null.
The behaviour is documented in Understanding the Date, TimeofDay, and DateTime property types and Date properties documentation.
if setting the property using loop please take care of Page clearance and parmeters if any accordingly
This is clearly documented in our Support Document Troubleshooting DateTime issues
@User16730164
Please follow below approach to sort down the issue more dynamically.
Step#1. to stop initializing 1970 from data source calls like making service call / running db query for date property null values you have to set below DSS as true as pega systems suggested which was an ootb java bug
Pega-IntegrationEngine(owning ruleset) • disableEpochData = true
Pega-IntegrationEngine • disableEpochDateTime = true
step#2 if you initiating date time properties every time you have check null pre condition before you mapping source date properties which will be redundant work for dev team. Hence please write below function code and invoke the function for you step pages which can flush the default date time / default date which initiating with 1970.Below is the Reusable function code -which you need to invoke on your step page which can dynamically identify all your date / date time properties which contains 1970 and set as null .
PublicAPI tools = ThreadContainer.get().getPublicAPI();
try {
if(SourcePage != null) {
ClipboardPage clipboardPage = tools.findPage(SourcePage);
java.util.Iterator iter = clipboardPage.values().iterator();
while(iter.hasNext()){
ClipboardProperty prop = (ClipboardProperty) iter.next();
if(prop.getTypeName().contains(“Date”)) {
if(prop.getStringValue().contains(“19700101”))
{
prop.setValue(“”);
}
}
}
}
} catch(Exception ex){
ex.printStackTrace();
}
Regards
Bhagath Vasireddy
Pega CLSA / J2EE Architect / AI expertise