S
Sterling Ledet
I am trying to create a web service that takes a string from my web server
in the following format:
Mon, 6 Oct 2003 18:39:47 UTC
and put's in a datetime so it can then be reformatted in C# as necessary
for variuos purposes.
There is something wrong with the following code. I get the following error
when I enter in the above date string:
System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.ParseFormatError(Boolean isThrowException, String
resourceID)
at System.DateTimeParse.DoStrictParse(String s, String formatParam,
DateTimeStyles styles, DateTimeFormatInfo dtfi, Boolean isThrowExp,
DateTime& returnValue)
at System.DateTimeParse.ParseExact(String s, String format,
DateTimeFormatInfo dtfi, DateTimeStyles style)
at System.DateTime.ParseExact(String s, String format, IFormatProvider
provider)
at DateTest.Service1.TestDate(String inputDate) in
\\commerce.ledet.com\wwwroot$\datetest\service1.asmx.cs:line 69
Can anyone tell me what's wrong with the code below??
[WebMethod]
public string TestDate(string inputDate)
{
// Define a custom string format to display the DateTime value.
// zzzz specifies the full time zone offset.
String expectedFormat = "ddd, d MMM yyyy hh:mm:ss";
System.DateTime ouputDateTime =
System.DateTime.ParseExact(inputDate, expectedFormat, null);
return ouputDateTime.ToString();
}
in the following format:
Mon, 6 Oct 2003 18:39:47 UTC
and put's in a datetime so it can then be reformatted in C# as necessary
for variuos purposes.
There is something wrong with the following code. I get the following error
when I enter in the above date string:
System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.ParseFormatError(Boolean isThrowException, String
resourceID)
at System.DateTimeParse.DoStrictParse(String s, String formatParam,
DateTimeStyles styles, DateTimeFormatInfo dtfi, Boolean isThrowExp,
DateTime& returnValue)
at System.DateTimeParse.ParseExact(String s, String format,
DateTimeFormatInfo dtfi, DateTimeStyles style)
at System.DateTime.ParseExact(String s, String format, IFormatProvider
provider)
at DateTest.Service1.TestDate(String inputDate) in
\\commerce.ledet.com\wwwroot$\datetest\service1.asmx.cs:line 69
Can anyone tell me what's wrong with the code below??
[WebMethod]
public string TestDate(string inputDate)
{
// Define a custom string format to display the DateTime value.
// zzzz specifies the full time zone offset.
String expectedFormat = "ddd, d MMM yyyy hh:mm:ss";
System.DateTime ouputDateTime =
System.DateTime.ParseExact(inputDate, expectedFormat, null);
return ouputDateTime.ToString();
}