Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

about dates with timezone

Posted on 2004-10-27
8
Medium Priority
?
220 Views
Last Modified: 2010-05-18
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?
0
Comment
Question by:FLUXWIRE
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
8 Comments
 
LVL 15

Expert Comment

by:Timbo87
ID: 12429054
Try this:

DateTime dt = DateTime.Parse("20050218T110000Z");
0
 

Author Comment

by:FLUXWIRE
ID: 12429112
I already had tried it before post this!

" String was not recognized as a valid DateTime"
this is the result.
0
 
LVL 15

Expert Comment

by:Timbo87
ID: 12429824
Is that date supposed to be Feb. 2, 2005?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:FLUXWIRE
ID: 12431452
no!
the date is Feb. 18, 2005 at 11:00
0
 
LVL 7

Expert Comment

by:God_Ares
ID: 12432288
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
 

Author Comment

by:FLUXWIRE
ID: 12432974
yes. this is a solution. an alternate solution.

this value is comming from the exchange appointment recurrence rules.

there is not another way?
0
 
LVL 7

Accepted Solution

by:
God_Ares earned 2000 total points
ID: 12433158
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
 

Author Comment

by:FLUXWIRE
ID: 12433861
thx. i agree!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question