about dates with timezone

Hi all!
I got dates in this format "20050218T110000Z" from Microsoft exchange properties.
This dates comes as strings and i need to parse it to select a date in a datepicker control.
but this format is not convertible.

Any ideas?
FLUXWIREAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Timbo87Commented:
Try this:

DateTime dt = DateTime.Parse("20050218T110000Z");
0
FLUXWIREAuthor Commented:
I already had tried it before post this!

" String was not recognized as a valid DateTime"
this is the result.
0
Timbo87Commented:
Is that date supposed to be Feb. 2, 2005?
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

FLUXWIREAuthor Commented:
no!
the date is Feb. 18, 2005 at 11:00
0
God_AresCommented:
looks like iso 8601  http://www.cl.cam.ac.uk/~mgk25/iso-time.html

just remove z,.. put some slashes in and some : and you are all set to parse it,..

                  string StringFromExchange = "20050218T110000Z";
                  string ToParse = StringFromExchange.Substring(0,StringFromExchange.Length-1).Insert(4,"-").Insert(7,"-").Insert(13,":").Insert(16,":");
0
FLUXWIREAuthor Commented:
yes. this is a solution. an alternate solution.

this value is comming from the exchange appointment recurrence rules.

there is not another way?
0
God_AresCommented:
if you can validate the returned dateformate is as described in  iso 8601,..  

you might reconise the format

//non compiled code here
MessageBox.Show(DateTime.Now.Tostring("s")); //should show something like 2004-10-18T14:48:33  

also these do

System.Globalization.DateTimeStyles.Exchange; //does not exsist ;)

hmm reading some text in the link i gave you,.. if a 'Z' is placed at the end it means the timezone is UTC

<quote>
Time Zone
Without any further additions, a date and time as written above is assumed to be in some local time zone. In order to indicate that a time is measured in Universal Time (UTC), you can append a capital letter Z to a time as in

23:59:59Z or 2359Z

[The Z stands for the "zero meridian", which goes through Greenwich in London, and it is also commonly used in radio communication where it is pronounced "Zulu" (the word for Z in the international radio alphabet). Universal Time (sometimes also called "Zulu Time") was called Greenwich Mean Time (GMT) before 1972, however this term should no longer be used. Since the introduction of an international atomic time scale, almost all existing civil time zones are now related to UTC, which is slightly different from the old and now unused GMT.]
</quote>

so you should  DateTiem.Parse(str).ToLocalTime(); //SOOOO important


in reply to your last statement,... what other way?,.. an other way to convert this string?  I'ts quite obvious it's an iso 8601 string,.. so my solution is OK!

if it aint the right solution for you,.. so be it,..

regards

Floris Briolas




0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FLUXWIREAuthor Commented:
thx. i agree!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.