xslt-1.0biztalkbiztalk-mapper

How to fix 'The string was not recognized as a valid DateTime.' error in BizTalk Test map?


I'm working on a BizTalk orchestrations with a map which contains an XSLT script. When I launch the orchestration I got this error

Error encountered while executing the transform. Error: Unable to create the transform.

So I go back to the map

XSL transform error: Unable to write output instance. Exception has been thrown by the target of an invocation. The string was not recognized as a valid DateTime. There is an unknown word starting at index 0.

I already tried to do a ParseExact but got the same error

Here is my code to convert DateTime:

public string FormatDate(string inputDate)
    {
      System.DateTime date = System.DateTime.Parse(inputDate);
      return date.ToString("yyyy-MM-dd");
    }

...and the code I tried with ParseExact:

public string FormatDate(string inputDate)
    {
      System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.InvariantCulture;
      System.DateTime date = System.DateTime.ParseExact(inputDate, "yyyyMMdd", culture);
      return date.ToString("yyyy-MM-dd");
    }

The expected result is to have the date with "yyyy-MM-dd" format.


Solution

  • The problem came from several scripting functoid with the same method name inside. Just gave each methods a different name and the errors has gone. Thank you to all users for your time.