Why is it that the seemingly simple things, cause you the most headaches.
Maybe it is just the day long pounding on the hard stuff, is making something that should be simple... more harder then it is.
Here is my issue/problem:
From an XML file, I have a Date-Time stated as:
YYYY-MM-DDTHH:MM:SS.0000Z
Example: 2008-08-29T19:00:00.000Z
Where Z is GMT...
I can read it fine from the XML and get it into a NSString object in my class.
----
Now, ultimately I need to go from that stored value to a Date/Time (right now just time) string value, but for a DIFFERENT timzone (my local timezone).
So in my class, I built a method to return that string as a NSCalendarDate object.
And this does appear to be return the object with the correct date/time in GMT.
But now I am stuck.
I don't know how to go the last step, to go from the NSCalendarDate object to a string, adjusted for my local timezone.
I have tried a few things, and I am getting to the point of frustration, so I am going to pack it up for today... but thought maybe I could ask here for some direction... as I know it has to be something simple I am just missing from the documentations.
Basically:
Start: NSString "2008-08-29T19:00:00.000Z"
End: NSString "2:00 pm"
(Central Daylight Savings Timezone)
If I can get it to the END style above, I am pretty sure then from the code I will be able to figure out how to get it to: "08/29/2008 2:00pm" and other formats.
Thanks for the help.
Maybe it is just the day long pounding on the hard stuff, is making something that should be simple... more harder then it is.
Here is my issue/problem:
From an XML file, I have a Date-Time stated as:
YYYY-MM-DDTHH:MM:SS.0000Z
Example: 2008-08-29T19:00:00.000Z
Where Z is GMT...
I can read it fine from the XML and get it into a NSString object in my class.
----
Now, ultimately I need to go from that stored value to a Date/Time (right now just time) string value, but for a DIFFERENT timzone (my local timezone).
So in my class, I built a method to return that string as a NSCalendarDate object.
Code:
-(NSCalendarDate *)getXMLDateTimeAsCalendarDate
{
return [NSCalendarDate dateWithString:[_XMLDateTime stringByReplacingOccurrencesOfString:@"Z" withString:@"GMT"] calendarFormat:@"%Y-%m-%dT%H:%M:%S.%F%Z"];
}
And this does appear to be return the object with the correct date/time in GMT.
But now I am stuck.
I don't know how to go the last step, to go from the NSCalendarDate object to a string, adjusted for my local timezone.
I have tried a few things, and I am getting to the point of frustration, so I am going to pack it up for today... but thought maybe I could ask here for some direction... as I know it has to be something simple I am just missing from the documentations.
Basically:
Start: NSString "2008-08-29T19:00:00.000Z"
End: NSString "2:00 pm"
(Central Daylight Savings Timezone)
If I can get it to the END style above, I am pretty sure then from the code I will be able to figure out how to get it to: "08/29/2008 2:00pm" and other formats.
Thanks for the help.