Using Scripting Functoid to convert EPOCH time to datetime string?

Home Page Forums BizTalk 2004 – BizTalk 2010 Using Scripting Functoid to convert EPOCH time to datetime string?

Viewing 2 reply threads
  • Author
    Posts
    • #19242

      Does anyone have experience doing this?

       When I try the following code:

      public string TririgaDateFormatter(string param)
      {
      double epocTime = Convert.ToDouble(param);
      System.DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0);
      dateTime = dateTime.AddSeconds(epocTime);
      param = dateTime.ToShortDateString() +” “+ dateTime.ToShortTimeString();
      return param;
      }

       It compiles fine but the map throws an error when I run a message through…

       am I missing something?

      Thanks in advane!

    • #19243

      I dont see any problem with the function.  What is the input message and exact error that you are getting?

    • #19244

      I am not sure what error you are getting, but the most common problem would be with the date format.  Return the date value in ISO_8601 format (YYYY-MM-DD).

      • #19245

        incoming date: 1201555165974

        error:
        Uncaught exception (see the ‘inner exception’ below) has suspended an instance of service ‘TririgaPurchaseReq.orcPurchaseReq(e74f271a-6da7-ec87-b7c7-7da89b31d87f)’.
        The service instance will remain suspended until administratively resumed or terminated.
        If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
        InstanceId: 7f70db58-dbf7-431a-b0c2-208b86c57b91
        Shape name: Construct Outgoing Purchase Req
        ShapeId: 8f9fb8e2-9318-449b-a98e-8ed543dec624
        Exception thrown from: segment 1, progress 6
        Inner exception: Error encountered while executing the transform TririgaPurchaseReq.PurchaseReqMapReqDetails. Error:Transformation failed..
               
        Exception type: XTransformationFailureException
        Source: Microsoft.XLANGs.Engine
        Target Site: Void ApplyInMemoryTransform(System.Type, Microsoft.XLANGs.RuntimeTypes.TransformMetaData, System.Object[], System.Object[])
        The following is a stack trace that identifies the location where the exception occured

        If I could output anything that would be great. When I take this scripting functoid out – the map works…

         

        • #19252

          Could it be that I am referencing a library that is not available in scripting functoids?

           

          • #19253

            You asked for the data being passwed in – The EPOCH date being passed in is:

            1201555165974

            I’ve isolated the problem to THIS functoid – I removed everything else from my map…

            Thanks

        • #19257

          Example Input: 1201555165974

          • #19261

            Okay – it seems this value is too long for a double…Can that be right?

             

            • #19262

              the value is definitely out of range.  i tried to call your function with this number.  i get this error.

               

              {“Value to add was out of range.\r\nParameter name: value”}

              • #19263

                the number of seconds that you are trying to add is creating a unrealistic date value.  i think there is something wrong with the input itself.

                • #19266

                  I am not sure that the logic to convert epoch time is appropriate, even though some of the forums say so.  i tried to execute your logic, but it fails.  Check out this link where I found that your input is working fine in a javascript program.  May be you can try to figure out the logic.

                  http://www.esqsoft.com/javascript_examples/date-to-epoch.htm

                  • #19275

                    Thank you ALL who contributed to this message!

                    I found that I needed to bring the variable in as a long and divide by 1000

                    EPOC time is based on MILLISECONDS! 

                     This works like a charm!

                    • #26461

                      so what does your current code in your scripting functoid look like? I am having this same issue

        • #19258

          Example Input: 1201555165974

Viewing 2 reply threads
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.