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. 3 7745
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.
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
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.
. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dan S |
last post by:
My application asks the user to enter in a date - in the mm/dd/yyyy format. Is there any quick and easy way to verify the date the user enters is formatted correctly? Right now I'm calling...
|
by: help |
last post by:
If I enable debug at C# exceptions, it dutifully breaks and shows me the stack
of called procedures. At the top (of my list) is DateTime.ParseExact() and it
does through an exception if I proceed....
|
by: Hans Merkl |
last post by:
Does anybody know of a library that can handle strings pf various formats
and conver them to a DateTime value? The strings are coming from a webform
and I can't restrict the input (it's not my...
|
by: ramon.smits |
last post by:
I'm trying to get the following date/time string formatted. But I don't
succeed. I get an exception saying the date/time string is invalid.
string input = "8/09/05 9:27a";
string format =...
|
by: news.microsoft.com |
last post by:
dim d as datetime
d = DateTime.Parse(#6/10/2004 11:50:40 PM#) produces exception "String was
not recognized as a valid DateTime."
d = DateTime.Parse("6/10/2004 11:50:40 PM") is OK
d =...
|
by: Cor Ligthert |
last post by:
Hello everybody,
Jay and Herfried are telling me every time when I use CDate that using the
datetime.parseexact is always the best way to do String to datetime
conversions. They don't tell why...
|
by: Pablo |
last post by:
Hello,
I have big problem with method ParseExact from class DateTime.
Here is code sample:
...
|
by: schouwla |
last post by:
How do I use DateTime.Parse or DateTime.ParseExact to create a
DateTime object from a string?
I tried this without luck:
string dateString = "27-02-2007";
// DateTime dt =...
|
by: csharpula csharp |
last post by:
Hello,
I am trying to add DataTime.Now.ToString() to a file name but I get an
exception while doing it that such format is not supported in path. How
can I solve this and cast this issue?
Thank...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |