Skip to Content
-1
Nov 07, 2018 at 03:21 AM

Date Time Format Conversion issue

1956 Views Last edit May 27, 2020 at 06:45 PM 2 rev

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 !