Requirement: How to add/ subtract no. of days from the coming Source data in Data Mapping?
Solution: Perform the following steps to add the DateUtils method.
- Download the attached DateUtils.class file and place it under the "<AdeptiaInstallationFolder>/ServerKernel/customClasses" folder:
- Restart the Adeptia services.
- Open a Data Mapping and in the bottom-right menu, you will see DateUtils() method under GlobalMethods.
- Now select the Target element and double click on this method and you can now use it in the Textual Rules mode.
There are 9 arguments that need to be passed in this function.
- Input Date
- Input Date Format
- Output Date Format
- Year needs to be added/subtracted
- Month needs to be added/subtracted
- Day needs to be added/subtracted
- Hour needs to be added/subtracted
- Minutes need to be added/subtracted
- Seconds need to be added/subtracted
An example to increment Date by 1 day:
java:DateUtils.DateAdd($TextFileSchema/Root/Record/MyDate, 'yyyy-MM-dd', 'yyyyMMdd', '0' , '0', '1', '0', '0', '0')
Note: To add/ subtract the hour, minutes, or seconds the input date must have the timestamp as part of its value.
Comments
1 comment
When using negative values (subtracting) and the Saxon XSL Transformer, you'll need to follow the steps in the Saxon XSL Transformer guide
Otherwise you'll receive an error similar to the one below
Article is closed for comments.