Date formatting for valid or invalid input dates

Adeptia Data Mapping uses Java Simple Date Format API to parse the input date and convert it into required format. By default, Simple Date Format is lenient in parsing the input date and it will accept any date as long as it is in the format you defined. While parsing, it simply rolls date over, for example June 32 becomes July 2 (reason for converting 20080632 to 2008-07-02 in below specified scenario) and December 0 becomes November 30.

To resolve the issue, we provide custom class that performs strict parsing of input date and make sure that date is in valid one and in proper format. After placing this custom class in “ServerKernel/customClasses” folder of the installed directory, you can use custom methods in mapping to achieve date formatting. Custom class name is “DateFormatter” and method to be invoked is “processDateFormat”. This custom method will intake 4 parameters:

· Input Date

· Input Format

· Output Format

· Default value to be returned in case Input Date is invalid

For example, if you call custom method with parameters "123456789", "yyyyMMdd", "yyyy-MM-dd", "Invalid Date" the output returned will be “Invalid Date”. Similarly if you call custom method with parameters "20080632", "yyyyMMdd", "yyyy-MM-dd", "" the output returned will be “”. If you call custom method with parameters "20080131", "yyyyMMdd", "yyyy-MM-dd", "" the output returned will be “2008-01-31” which looks good.

Refer to the java class and the instructions (in ppt).

Have more questions? Submit a request

0 Comments

Article is closed for comments.