Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

Unable to convert datetime to yyyy-MM-dd format

SA-14171

Summary



Unable to convert datetime to yyyy-MM-dd format and an exception occurs. On a datetime property, the user should be able to set date in format yyyy-MM-dd. Connector & Metadata wizard is used to create Parse/Stream rules. 


Error Messages



2015-07-01 is not a valid date format


Steps to Reproduce



1. Run the Connector & Metadata wizard to create properties, Parse and Stream rules.
2. In Data Tansform, assign the DateTime value to String property.
3. Run the activity which invokes DT Created in Step2.

Root Cause



A defect in Pegasystems’ code or rules. User assigned String returned output to DateTime property which is unexpected. There is no OOTB way to convert the date value to yyyy-MM-dd format and assign it to DateTime property.

Resolution



Perform the following local-change:

1. Perform Save-as of OOTB function, FormatDateTime to custom ruleset.

2. Change the Output Java Data Type to Date.

3. Add below piece of code to Java.

DateTimeUtils dtu = ThreadContainer.get().getDateTimeUtils();

return PRDateFormat.parseXSDDate(dtu.formatDateTime(strDateTime, strPattern, strTimeZone, strLocale));

4. Save the function and Compile and Generate Function .

5. MsgPutTime is a DateTime property.

6. Assign the values to DT for DateTime property.

@(IAC:DateTime).TestFun("20090109T162504.370 GMT", "yyyy-MM-dd", "", "")

7. Call the Parser rules using this DT with DateTime property as an input.

<pagedata><Test><shiporder> <orderperson>Test</orderperson> <MsgPutTime>2009-01-09T00:00:00.000Z</MsgPutTime> </shiporder> </Test><orderperson>Test</orderperson><MsgPutTime2>20090109T000000.000 GMT</MsgPutTime2><pxObjClass>PegaSample-Int-Shiporder</pxObjClass><pzStatus>valid</pzStatus></pagedata>

Published October 23, 2015 - Updated October 8, 2020

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us