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
Most commonly used notation:
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
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
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
Because offset can be different depending on the day and month for daylight savings time, milliseconds and offset are removed using substring function.
References:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 34 | |
| 9 | |
| 9 | |
| 5 | |
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 |