473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Parsing a complicated date time

Hi,

I'm trying to parse the following date "Wed, 18 Dec 2002 08:01:23 +0100
(MET)".

I'm using the following code:

System.IFormatProvider format = new
System.Globalization.CultureInfo("sv-SE", true);
parsedDate = DateTime.ParseExact("Wed, 18 Dec 2002 08:01:23 +0100
(MET)", "dd MMM yyyy hh:mm:ss", format,
System.Globalization.DateTimeStyles.AllowWhiteSpac es);

But this leads to errors.

Anyone have any idea how I can parse this date without having to mash
the string up too much?

Thanks,

Campbell

Jul 13 '06 #1
3 1684
The string you have is language dependent and it's clearly not Swedish. Try
"en-US" instead and this format string:
@"ddd, dd MMM yyyy hh:mm:ss zzz \(\M\E\T\)"

Where do you get the string from?

/claes

<ca**************@gmail.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
Hi,

I'm trying to parse the following date "Wed, 18 Dec 2002 08:01:23 +0100
(MET)".

I'm using the following code:

System.IFormatProvider format = new
System.Globalization.CultureInfo("sv-SE", true);
parsedDate = DateTime.ParseExact("Wed, 18 Dec 2002 08:01:23 +0100
(MET)", "dd MMM yyyy hh:mm:ss", format,
System.Globalization.DateTimeStyles.AllowWhiteSpac es);

But this leads to errors.

Anyone have any idea how I can parse this date without having to mash
the string up too much?

Thanks,

Campbell

Jul 13 '06 #2
Claes,

That works a treat!

The string came in through some XML I got from a Swedish company.

I'm trying to tidy it up before I do anything with it in BizTalk.

Many thanks,

Campbell.
Claes Bergefall wrote:
The string you have is language dependent and it's clearly not Swedish. Try
"en-US" instead and this format string:
@"ddd, dd MMM yyyy hh:mm:ss zzz \(\M\E\T\)"

Where do you get the string from?

/claes

<ca**************@gmail.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
Hi,

I'm trying to parse the following date "Wed, 18 Dec 2002 08:01:23 +0100
(MET)".

I'm using the following code:

System.IFormatProvider format = new
System.Globalization.CultureInfo("sv-SE", true);
parsedDate = DateTime.ParseExact("Wed, 18 Dec 2002 08:01:23 +0100
(MET)", "dd MMM yyyy hh:mm:ss", format,
System.Globalization.DateTimeStyles.AllowWhiteSpac es);

But this leads to errors.

Anyone have any idea how I can parse this date without having to mash
the string up too much?

Thanks,

Campbell
Jul 13 '06 #3
If possible you should tell then to change the format to standard ISO (which
happens to be what Sweden uses anyway), i.e. "yyyy-MM-dd hh:mm:ss". Or even
better, tell them to use the standard XML date data type. Will make it a lot
easier for you. If that's not possible you can at least ask them how they
generate it. The sample you provided seems to have been generated with an
English culture, but that might just be a coincidence in this particular
case.

/claes

<ca**************@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Claes,

That works a treat!

The string came in through some XML I got from a Swedish company.

I'm trying to tidy it up before I do anything with it in BizTalk.

Many thanks,

Campbell.
Claes Bergefall wrote:
>The string you have is language dependent and it's clearly not Swedish.
Try
"en-US" instead and this format string:
@"ddd, dd MMM yyyy hh:mm:ss zzz \(\M\E\T\)"

Where do you get the string from?

/claes

<ca**************@gmail.comwrote in message
news:11*********************@m73g2000cwd.googlegr oups.com...
Hi,

I'm trying to parse the following date "Wed, 18 Dec 2002 08:01:23 +0100
(MET)".

I'm using the following code:

System.IFormatProvider format = new
System.Globalization.CultureInfo("sv-SE", true);
parsedDate = DateTime.ParseExact("Wed, 18 Dec 2002 08:01:23 +0100
(MET)", "dd MMM yyyy hh:mm:ss", format,
System.Globalization.DateTimeStyles.AllowWhiteSpac es);

But this leads to errors.

Anyone have any idea how I can parse this date without having to mash
the string up too much?

Thanks,

Campbell

Jul 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
3
by: dont bother | last post by:
Hey, I have been trying to parse emails: But I could not find any examples or snippets of parsing emails in python from the documentation. Google did not help me much too. I am trying to...
22
by: Willem Ligtenberg | last post by:
I want to parse a very large (2.4 gig) XML file (bioinformatics ofcourse :)) But I have no clue how to do that. Most things I see read the entire xml file at once. That isn't going to work here...
9
by: Thomas W | last post by:
I'm developing a web-application where the user sometimes has to enter dates in plain text, allthough a format may be provided to give clues. On the server side this piece of text has to be parsed...
16
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed...
6
by: Kalle Anke | last post by:
I want to parse a date string, for example '2005-09-23', and since I haven't done this before I would like to ask what is the best way to do it. I've looked around and the dateutil seems to be...
26
by: jshanman | last post by:
I am writing a timeline that uses Google Maps. I have a function that converts a date time to latitude coords. This function is used to draw the markers on the timeline. I need a reverse function...
9
by: ankitdesai | last post by:
I would like to parse a couple of tables within an individual player's SHTML page. For example, I would like to get the "Actual Pitching Statistics" and the "Translated Pitching Statistics"...
13
by: Chris Carlen | last post by:
Hi: Having completed enough serial driver code for a TMS320F2812 microcontroller to talk to a terminal, I am now trying different approaches to command interpretation. I have a very simple...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.