Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Using Scripting Functoid to convert EPOCH time to datetime string?
- This topic has 13 replies, 1 voice, and was last updated 9 years, 2 months ago by
community-content.
-
AuthorPosts
-
-
April 3, 2008 at 10:54 AM #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!
-
April 3, 2008 at 11:11 AM #19243
I dont see any problem with the function. What is the input message and exact error that you are getting?
-
April 3, 2008 at 11:23 AM #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).
-
April 3, 2008 at 11:29 AM #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 occuredIf I could output anything that would be great. When I take this scripting functoid out – the map works…
-
April 4, 2008 at 8:16 AM #19252
Could it be that I am referencing a library that is not available in scripting functoids?
-
April 4, 2008 at 8:18 AM #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
-
-
April 4, 2008 at 9:29 AM #19257
Example Input: 1201555165974
-
April 4, 2008 at 12:27 PM #19261
Okay – it seems this value is too long for a double…Can that be right?
-
April 4, 2008 at 1:37 PM #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”}
-
April 4, 2008 at 1:59 PM #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.
-
April 6, 2008 at 6:45 PM #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
-
April 7, 2008 at 10:12 AM #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!
-
October 21, 2014 at 12:42 PM #26461
so what does your current code in your scripting functoid look like? I am having this same issue
-
-
-
-
-
-
-
April 4, 2008 at 9:29 AM #19258
Example Input: 1201555165974
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.