Time zone conversion is not often used in Integration Suite, as date and time are mostly converted to different time zone in target system for most integrations. More recently however, with more standardized and cloud systems being used (e.g S4HANA Cloud), as well as prepackaged API's, time zone conversion has become more common. In addition, most countries use daylight savings time, which requires a different time offset depending on the day and month for date and time.
For SAP PO, the most common way to convert date and time to a different timezone is to use java libraries for Joda-Time in a user defined function to convert date and time to a different timezone. For Integration Suite, these libraries can be used by default in groovyscript. Following an earlier post with an example of how to use these libraries in groovy, as well as some changes to the code to make the function more generic, the code can be used in message mapping to convert date and time to a different timezone.
import java.util.TimeZone;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
def String converttimezone(String input, String pattern, String totimezone) {
//set output to empty
def output = "";
//if input is not empty, convert input to timezone
if (input != "") {
DateTimeFormatter dtformatter = DateTimeFormat.forPattern(pattern);
DateTime datetime = dtformatter.parseDateTime(input);
TimeZone timezone = TimeZone.getTimeZone(totimezone);
output = datetime.withZone(DateTimeZone.forTimeZone(timezone)).toString();
}
return output;
}The function uses parameters input, pattern and totimezone to convert a date and time to a different timezone
- input: date and time with offset or timezone (e.g 2026-03-26T18:00:00+01:00)
- pattern: format for date and time, using notation for SimpleDateFormat
Most commonly used notation:
- y - year
- M - month
- d - day
- H - hour
- m - minutes
- s - seconds
- S - milliseconds
- Z - time offset (e.g +01:00, +0100)
- ZZZ - time zone (e.g UTC, Europe/Amsterdam); this can be any identifier for time zone Any text which is not part of the date and time notation can be enclosed in apostrophe (e.g yyyy-MM-dd'T'HH:mm:ss)
- totimezone: any identifier for time zone (e.g UTC, Europe/Amsterdam)
The output date and time format for the function is always the same, either yyyy-MM-dd'T'HH:mm:ss.SSS'Z' (e.g 2026-03-26T18:00:00Z) when converting date and time to UTC, or yyyy-MM-dd'T'HH:mm:ss.SSSZ (e.g 2026-03-26T18:00:00+01:00) for any other time zone. If needed, the standard datetrans function can be used in message mapping to change the date and time to a different format.
Examples
Example 1: convert date and time with offset (e.g 2026-03-26T18:00:00+01:00) to UTC
In this case date and time with offset is used from source message and converted to UTC timezone
- input: date and time with offset (2026-03-26T18:00:00+01:00)
- pattern: date and time with offset (yyyy-MM-dd'T'HH:mm:ssZ)
- totimezone: UTC
After converting date and time to UTC, the format is changed to remove milliseconds using datetrans function (format yyyy-MM-dd'T'HH:mm:ss.SSS'Z' to yyyy-MM-dd'T'HH:mm:ss)
Example 2: convert date and time without offset from timezone CET to timezone UTC
In this case date and time is used without offset and timezone has to be added before converting date and time to different timezone
- input: date and time, timezone is CET and is added using concat function (e.g 2026-02-25 17:59:23 CET)
- pattern: date and time with offset (yyyy-MM-dd HH:mm:ss ZZZ)
- totimezone: timezone is UTC
After converting date and time to UTC, format is changed back to original using datetrans function (format yyyy-MM-dd'T'HH:mm:ss.SSS'Z' to yyyy-MM-dd HH:mm:ss)
Example 3: convert date and time from timezone UTC to timezone Europe/Amsterdam
- input: date and time, timezone is added (e.g 2026-08-27T12:00:00 UTC)
- pattern: date and time with timezone (yyyy-MM-dd'T'HH:mm:ss ZZZ)
- totimezone: date and time is set to timezone Europe/Amsterdam
Because offset can be different depending on the day and month for daylight savings time, milliseconds and offset are removed using substring function.
References:
- Timezone conversion for SAP PO: https://community.sap.com/t5/technology-blog-posts-by-members/time-zone-conversion-in-pi-mapping/ba-p/13156873
- Earlier example of function to convert date and time to different timezone: https://stackoverflow.com/questions/45834774/groovy-date-timezone-formatting
- Full list of class SimpleDateFormat, used for date and time notation: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
- List of all timezones: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.