Skip to Content

HCI : Conversion of Date Format in Hana Cloud Integration

Dear Experts ,

i have a requirement where i need to convert the date format .for example the input format is 23.05.2017 where as expected format is 2017-05-23T00:00:00.000 . i am using the hana cloud integration as a middleware .Please provide the udf to achieve this requirement.

Regards

Giridhar Vegi.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • May 23, 2017 at 11:27 AM

    Hello Giridhar,

    Below UDF will do the same.

    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);  
    
        DateFormat dateFormat_required = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS");
    
        def converted_datetime=dateFormat_required.format(inputDate_parsed);
        
        return converted_datetime;
    }

    Regards,

    Sriprasad Shivaram Bhat

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Sriprasad,

      I have a requirement to convert current date time value from UTC to other timezone in SAP CPI-PI.

      Actually I am using below date now function to get the current date time.

      ${date:now:dd-MM-yyyy HH:mm z}

      But by default I am getting value in UTC timezone.

      I am expecting date time value in EET timezone.

      Can this be achieved using groovy script.?

      Regards,

      Deva

  • May 24, 2017 at 05:31 AM

    Dear prasad,

    Thanks alot for your support. but i am getting the error as attached in the screenshot. please suggest me on this.svkm-unparsable-error.jpg if i have given single record.if i have given multiple records i am getting the error as follows.

    java.lang.ClassCastException: Cannot cast class java.util.ArrayList to class java.util.HashMap

    For reference i am attaching the following input file that needs to be mapped.attandance.jpg .

    Also i am getting the following error

    com.sap.gateway.core.ip.component.odata.exception.OsciException: Request Payload: Either the OData metadata content available in the server is outdated or the request payload seems to be incorrect = https://api8preview.sapsf.com/odata/v2_defaultTenant_shrivilepaT with error => Cannot convert 20170523 000000.000 to java.util.Calendar

    please suggest me on this.

    Regards

    Giridhar Vegi.

    Add comment
    10|10000 characters needed characters exceeded