We may need to create a date value in header/property, which could we use in the filter at a later point.
Can be easily achieved using groovy script. Usually its very easily with normal java util class. But problems come when we have to add this based on a particular timezone. Code below :
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import java.time.ZonedDateTime
import java.time.ZoneId
import java.time.format.DateTimeFormatter;
def Message processData(Message message) {
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("Europe/Berlin"));
futureLimitDate = now.plusDays(30).format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'"));
println futureLimitDate
message.setProperty("futureLimitDate", futureLimitDate);
return message;
}
That’s it. Happy Coding. :B
Tags: add date, groovy, groovyscript, java date, sap cloud platform integration, SCPI
Leave a comment