Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-14-2011, 06:11 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2009
Location: Lahore, Pakistan
Posts: 32
stolidimran is on a distinguished road
Send a message via MSN to stolidimran Send a message via Yahoo to stolidimran Send a message via Skype™ to stolidimran
Question dateFromString returns nil on iOS 4.2, works fine on 3.2!

I am converting a string returned from server to NSDate object for further use.

Here is the sample string from server:
Code:
2011-01-14T16:05:48.555+05:00
And, I use
Code:
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss"];
I am able to successfully convert it to an NSDate object using dataFromString method on iOS 3.2 (device & sim both).

However, the same code returns nil on iOS 4.2 on device & sim both.

I have also tried many variations of date format patterns such as:

Code:
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZZZZ"];
[dateFormatter setDateFormat:@"YYY-MM-DD'T'HH:mm:ss.fffK"];
but nothing works!!

Am I missing something here?

EDIT: I tried to hard-code the input string and after trying many variations, the following string
Code:
2011-01-14T16:05:48.555+0500
worked with
Code:
"yyyy-MM-dd'T'HH:mm:ss.SSSZ"
Notice that the only difference in this string and the one from server is; the colon (:) in TimeZone value. I tried to find a date pattern where I can mention the colon in timezone with no success.

Any clue??
__________________
“Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.” Anonymous

Follow me on Twitter
http://twitter.com/stolidimran

Last edited by stolidimran; 01-14-2011 at 06:14 AM.
stolidimran is offline   Reply With Quote
Reply

Bookmarks

Tags
4.2, iphone, nsdate, nsdateformatter, nsstring

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 367
10 members and 357 guests
7twenty7, blueorb, dre, iAppDeveloper, iGamesDev, Mah6447, Morrisone, mottdog, sacha1996, Touchmint
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:36 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0