DateTime.Parse .. what's different in .NET 1.1

  • Thread starter Thread starter Atul Agarwal
  • Start date Start date
A

Atul Agarwal

Hello

In .NET 1.0, the following code worked fine


public string dateFormat = "yyy-MM-dd\"T\"HH:mm:ss.fff zzz";
DateTime date, minDate;

date = DateTime.Parse(minDate.ToString(dateFormat));

In .NET 1.1 I get an System.Format exception
For Example, this generates a System.Format exception

DateTime.Parse("2003-08-23T20:50:05.365 +05:30");

Is something changed in .NET 1.1 ?

Thanks

Atul Agarwal
(e-mail address removed)
 
Ah .. apologies my mistake. But in any case that was not the source
of the problem.

In .NET 1.1, this throws a SystemFormat exception
DateTime.Parse("2003-08-23T20:50:05.365 +05:30");
but it worked fine in .NET 1.0.

It is the extra space before the timezone which is the cause of
the problem. It is not standard ISO8601 format.
Thus the following format string should have been used

"yyyy-MM-dd\"T\"HH:mm:ss.fffzzz";

Atul Agarwal
 
Yan-Hong Huang said:
If there is no T inside the string, the string could be parsed correctly.
Could you please let us know why there is a T in the string?

Presumably because it was meant to be ISO8601 compliant, which means
including a T. From the MSDN sample of output patterns, using standard
formatter s which (according to the docs) conforms to 8601:

2001-04-10T15:51:24

Also from the MSDN:

<quote>
The property references the CultureInfo.InvariantCulture property, and
the format follows the custom pattern "yyyy-MM-ddTHH:mm:ss".
</quote>

The T should definitely be there as far as I can see.
 
Hello Atul and Jon,

After working with product group, we have confirmed that it is a product
issue here. It has been fixed in the next version of VS.NET.

Here are some work around options:

1. Configure the source of the data to not format the dates with a space.
2. Use PaseExact('yyyy-MM-dd'T'HH:mm:ss.fff zzz') instead.
3. Clean up the data using String.Replace or a Regex replace.

Please post here to let us know if you have follow up questions. Thanks
very much for your feedback on the product. We appreciate it very much.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: Jon Skeet <[email protected]>
!Subject: Re: DateTime.Parse .. what's different in .NET 1.1
!Date: Mon, 25 Aug 2003 19:25:34 +0100
!Message-ID: <[email protected]>
!References: <[email protected]>
<OQ#[email protected]>
<[email protected]>
<[email protected]>
!Organization: Peramon Technology Ltd.
!X-Newsreader: MicroPlanet Gravity v2.60
!Newsgroups: microsoft.public.dotnet.framework
!NNTP-Posting-Host: pc3-rdng5-6-cust64.winn.cable.ntl.com 81.103.154.64
!Lines: 1
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:52161
!X-Tomcat-NG: microsoft.public.dotnet.framework
!
!> If there is no T inside the string, the string could be parsed
correctly.
!> Could you please let us know why there is a T in the string?
!
!Presumably because it was meant to be ISO8601 compliant, which means
!including a T. From the MSDN sample of output patterns, using standard
!formatter s which (according to the docs) conforms to 8601:
!
!2001-04-10T15:51:24
!
!Also from the MSDN:
!
!<quote>
!The property references the CultureInfo.InvariantCulture property, and
!the format follows the custom pattern "yyyy-MM-ddTHH:mm:ss".
!</quote>
!
!The T should definitely be there as far as I can see.
!
!--
!Jon Skeet - <[email protected]>
!http://www.pobox.com/~skeet/
!If replying to the group, please do not mail me too
!
 
Back
Top