Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How do I parse ZULU DateTime string

Posted on 2009-07-11
3
Medium Priority
?
997 Views
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.
Thanks

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

0
Comment
Question by:mohammad1000
[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
3 Comments
 
LVL 15

Expert Comment

by:oobayly
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

0
 

Author Comment

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

Accepted Solution

by:
jinal earned 80 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

0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

661 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