When integrating systems in Oracle Integration Cloud (OIC), it is common to receive date-time values in UTC format as strings from source systems. Sometimes downstream systems require the date-time in a different timezone, such as Hong Kong Time (HKT).
In this blog, we will see how to convert a UTC datetime string into Hong Kong time using XPath functions inside OIC.
Problem Statement
The source system sends a datetime value in UTC format as a string:
2026-01-29T10:00:00Z
But the target system expects the time in Hong Kong timezone (UTC +8).
So we need to:
- Convert the string to xsd:dateTime
- Adjust the timezone to +8 hours
- Format the output datetime.
Solution
We can use the XPath functions adjust-dateTime-to-timezone and format-dateTime.
XPath Expression
xp20:format-dateTime(
fn:adjust-dateTime-to-timezone(
xsd:dateTime("2026-01-29T10:00:00Z"),
xsd:dayTimeDuration("PT8H")
),
"[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]Z"
)
Explanation
1. Convert String to DateTime
xsd:dateTime("2026-01-29T10:00:00Z")
This converts the string value into an XML datetime format.
2. Adjust Timezone
fn:adjust-dateTime-to-timezone(... , xsd:dayTimeDuration("PT8H"))
PT8H means plus 8 hours
Hong Kong timezone is UTC +8
So the system adjusts the time accordingly.
Example:
UTC Time
Hong Kong Time
2026-01-29T10:00:00Z
2026-01-29T18:00:00
3. Format the Output
xp20:format-dateTime(...,"[Y0001]-[M01]-[D01]T[H01]:[m01]:[s01]Z")
This formats the datetime into a standard ISO format.
Output:
2026-01-29T18:00:00Z
When to Use This
This approach is useful when:
Source system sends UTC timestamps
Target system expects local timezone
Integration logic is implemented in OIC mapper expressions
Typical scenarios include:
ERP integrations
HR systems
Global payroll or workforce systems
Cross-region API integrations
Key Takeaways
OIC supports timezone manipulation using XPath functions.
adjust-dateTime-to-timezone helps convert UTC to any timezone.
PT8H represents 8 hours offset for Hong Kong time.
Always convert string → xsd:dateTime before timezone adjustment.

No comments:
Post a Comment