How do I parse ZULU DateTime string

Posted on 2009-07-11
Last Modified: 2012-05-07
I need to be able to correctly parse a string to a DateTime type using the DateTime.ParseExact.
Any suggestion would be appreciated.

CultureInfo provider = CultureInfo.InvariantCulture;
            string dateString = "091128Z July 2009";
            string format = "ddHHmmZ MMM yyyy";
            DateTime result;
            result = DateTime.ParseExact( dateString, format, provider );
The result should be   09/07/2009   11:28 AM

Open in new window

Question by:mohammad1000
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
LVL 15

Expert Comment

ID: 24832254
You've specified the format string to parse the month as an abbreviated string. Try this:
string format = "ddHHmmZ MMMM yyyy";

Open in new window


Author Comment

ID: 24832414
Changing the format type gives incorrect time.
091128Z July 2009 converts to 7/9/2009 4:28:00 AM.

The result should be 7/9/2009  11:28 AM.
LVL 15

Accepted Solution

jinal earned 20 total points
ID: 24832827
You have to call ToUniversalTime at last.
            DateTime dt = result.ToUniversalTime();

CultureInfo provider = CultureInfo.InvariantCulture;
            string dateString = "091128Z July 2009";
            string format = "ddHHmmZ MMMM yyyy"; 
            DateTime result;
            result = DateTime.ParseExact(dateString, format,provider);
            DateTime dt = result.ToUniversalTime();

Open in new window


Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
array not updating 8 42
How we can add Dten600.dll in GAC in c#. 18 55
Easiest intro into .NET CORE? 2 32
Unable to Install .NET 3.5 on Windows 2012 server 4 14
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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