on 2022 Jul 13 4:27 AM
Hi All,
I have an Odata response in JSON format where the invoice date is passed as a timestamp. The standard JSON to XML convert function works well except the date.
<CGROSS_AMOUNT_CU>USD</CGROSS_AMOUNT_CU><br><CINVOICE_DATE>/Date(1645660800000)/</CINVOICE_DATE><br><CINVOICE_UUID>028</CINVOICE_UUID>
I have a requirement to covert /Date(1645660800000)/ to yyyy-MM-dd for an XML mapping. The date trans function within the message mapping didn't covert correctly. What is the easiest method? Thanks.
Hello Gabrielu.
Check below groovy script to convert EPOCH time stamp, it will directly give you date. You can manipulate time zone as per your requirment.
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.*;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.ZonedDateTime;
def Message processData(Message message) {
map = message.getProperties();
Instant i=Instant.ofEpochMilli(1645660800000)
ZonedDateTime z=i.atZone(ZoneId.of("Asia/Calcutta"))
LocalDate date=z.toLocalDate()
message.setProperty("CINVOICE_DATE", date);
return message;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
69 | |
11 | |
10 | |
10 | |
9 | |
9 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.