469,077 Members | 1,339 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,077 developers. It's quick & easy.

DateTime.ParseExact( ) Exception

I'm trying to parse a string into a DateTime object. I
want to try using ParseExact to see if I can improve
performance of a frequently-called method (i.e., please
don't suggest using Parse()). My code looks like this:

IFormatProvider fp = new System.Globalization.CultureInfo
("en-US");
DateTime dt = DateTime.ParseExact("Mar 9, 2005", "MMM d,
yyyy", fp);

This throws an exception in MatchAbbreviatedMonthName()
(an FCL method). If I look at the CultureInfo object,
there is, in fact, a month called "Mar".

How can I use my custom format with ParseExact?

Thanks!

Dave P.

Nov 16 '05 #1
3 7581
Dave,
That is very odd - I just tried the code snippet on my machine and it worked
fine?

What version of the Framework are you using? Also, what OS?

--
Nathan

"Dave P." <an*******@discussions.microsoft.com> wrote in message
news:70****************************@phx.gbl...
I'm trying to parse a string into a DateTime object. I
want to try using ParseExact to see if I can improve
performance of a frequently-called method (i.e., please
don't suggest using Parse()). My code looks like this:

IFormatProvider fp = new System.Globalization.CultureInfo
("en-US");
DateTime dt = DateTime.ParseExact("Mar 9, 2005", "MMM d,
yyyy", fp);

This throws an exception in MatchAbbreviatedMonthName()
(an FCL method). If I look at the CultureInfo object,
there is, in fact, a month called "Mar".

How can I use my custom format with ParseExact?

Thanks!

Dave P.

Nov 16 '05 #2
Dave P. <an*******@discussions.microsoft.com> wrote:
I'm trying to parse a string into a DateTime object. I
want to try using ParseExact to see if I can improve
performance of a frequently-called method (i.e., please
don't suggest using Parse()). My code looks like this:

IFormatProvider fp = new System.Globalization.CultureInfo
("en-US");
DateTime dt = DateTime.ParseExact("Mar 9, 2005", "MMM d,
yyyy", fp);

This throws an exception in MatchAbbreviatedMonthName()
(an FCL method). If I look at the CultureInfo object,
there is, in fact, a month called "Mar".

How can I use my custom format with ParseExact?


Like Nathan, it works for me. What exception is thrown? Have you tried
searching for it on Google?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
FCL version 1.1, OS Win2k server.

I don't have repro handy at the moment, but the exception
was FormatException, I think. Whatever it was, it was an
indication that the format string could not be used for
the date string.

I have done a Google search on this and haven't found
anything, which is why I'm posting here. But always a
good idea.

Dave
-----Original Message-----
Dave,
That is very odd - I just tried the code snippet on my machine and it workedfine?

What version of the Framework are you using? Also, what OS?
--
Nathan

"Dave P." <an*******@discussions.microsoft.com> wrote in messagenews:70****************************@phx.gbl...
I'm trying to parse a string into a DateTime object. I
want to try using ParseExact to see if I can improve
performance of a frequently-called method (i.e., please
don't suggest using Parse()). My code looks like this:

IFormatProvider fp = new System.Globalization.CultureInfo ("en-US");
DateTime dt = DateTime.ParseExact("Mar 9, 2005", "MMM d,
yyyy", fp);

This throws an exception in MatchAbbreviatedMonthName()
(an FCL method). If I look at the CultureInfo object,
there is, in fact, a month called "Mar".

How can I use my custom format with ParseExact?

Thanks!

Dave P.

.

Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Dan S | last post: by
4 posts views Thread by Hans Merkl | last post: by
3 posts views Thread by news.microsoft.com | last post: by
11 posts views Thread by Cor Ligthert | last post: by
1 post views Thread by Pablo | last post: by
1 post views Thread by schouwla | last post: by
3 posts views Thread by csharpula csharp | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.