cancel
Showing results for 
Search instead for 
Did you mean: 

Date Time Format Conversion issue

arnab_mondal2
Participant
0 Kudos

Hi Experts, I need to change the date format from

yyyy-MM-dd HH:mm:ss to yyyy-MM-ddT00:00:00:0000000Z

I tried the groovy script , but just not able to handle the last 8 digits

******************************************************************************************

import com.sap.it.api.mapping.*; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; //Add MappingContext as an additional argument to read or set Headers and properties. def String customFunc(String arg1){ //Date inputDate_parsed=new SimpleDateFormat("dd.MM.yyyy").parse(arg1); Date inputDate_parsed=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(arg1); DateFormat dateFormat_required = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:z"); def converted_datetime=dateFormat_required.format(inputDate_parsed); return converted_datetime; }

******************************************************************************************

Experts , can you please help quickly - what am I doing wrong !

arnab_mondal2
Participant
0 Kudos

Experts I did try changing to new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:fffffffz") - but system could not identify it !

Accepted Solutions (1)

Accepted Solutions (1)

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Arnab,

Instead of ff use SSSSSS it should work.

Regards,

Sri

Answers (1)

Answers (1)

Sriprasadsbhat
Active Contributor
0 Kudos

Hello Arnab,

I could see uou are using custom function for date transformation,,could you please try with standard date function available in message mapping which is very handy i guess and it will work for sure.

Regards,

Sriprasad Shivaram Bhat