Requirement:
As a feature of message enrichment we need to modify/update message from its original value to something what required by target system. If you are using OSB as your Middleware you can do that easily using xQuery built-in function.
Functions Details:
- Numeric Operator: + & –
- To subtract or add date
- xs:dayTimeDuration
(
xs: string$string-var)
- To set duration that we want to add or subtract
- xs:date() or xs:dateTime()
- To convert string data in to date native
How to Use:
The xs:date() or xs:dateTime() is used for just type cast to convert a string to date/dateTime so that we can apply numeric function + or –
The value that we need to add or subtract is handled by function xs:dayTimeDuration(xs:string $string-var) where input parameter xs:string can be provided as “PdDThHiMsS”
PdDThHiMsS as :
P = Fix value need to pass
dD= d-> Number of Days | D -> is constant
T = Fix value to indicate start of Time Fields
hH = h-> Number of Hours | H -> is constant
iM= i -> Number of Minutes | M -> is constant
sS= s -> Number of Seconds | S -> is constant
Example:
Input: InputDate is in format YYYY-MM-DDThh:mm:ss (Standard)
Example 1: __________________________________________________________________
Add 10 Days: { xs:date(normalize-space(data(ns0:InputDate))) + xs:dayTimeDuration(“P10D”) }
In: 2020-05-24 Out: 2020-06-03
Example 2: __________________________________________________________________
Subtract 50 Days: { xs:date(normalize-space(data(ns0:InputDate))) – xs:dayTimeDuration(“P50D”) }
In: 2020-01-10 Out: 2019-11-21
Example 3:__________________________________________________________________
Add 30 Days 10 Hours 30 Minutes 30 Seconds: { xs:dateTime(normalize-space(data($employeeRecord1/ns1:StartDate))) + xs:dayTimeDuration(“P30DT10H30M30S”) }
In: 2020-02-10T20:00:00 Out: 2020-03-12T06:30:30
Example 4: __________________________________________________________________
Subtract 1 Day 1 Hour 30 Minutes 15 Seconds: { xs:dateTime(normalize-space(data($employeeRecord1/ns1:StartDate))) – xs:dayTimeDuration(“P1DT1H30M15S”) }
In:2020-01-10T20:00:00 Out:2020-01-09T18:29:45
Hope you got some ideas to achieve your requirement.
______________________________________________________________________________
I Love Cooking Too, Please visit my Cooking Channel on YouTube: https://www.youtube.com/c/priyashreefoodfashion
Please do Subscribe on YouTube if you are a foodie too 🙂