By the way, I can readily confirm that the results differ on the simulator for 4.3 vs. 5.0. m.
>On Fri, 11 Nov 2011 16:13:49 +0800, Kin Mak <kin...@me.com> said: >>The following code used to work fine prior to iOS 5. The dateFromString >>method seems to stop working on iOS 5 and always returns null. I suspect this >>is a bug introduced in iOS 5.0. Have anyone encountered the same issue? Or >>do I miss something here? >> >> NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; >> [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS zzz"]; >> >> ..... >> //E.g currentString = @"2011-11-11 11:00:00.000 CET"; >> NSDate *date = [dateFormatter dateFromString:currentString]; > >It works for me if I substitute "PST" for your "CET" - could the "CET" be the >problem? > >I guess what I would do is start by testing whether the date formatter can >round-trip its own output, like this: > > NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; > [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS zzz"]; > NSString* output = [dateFormatter stringFromDate:[NSDate date]]; > NSLog(@"%@", output); > > NSDate* date = [dateFormatter dateFromString: output]; > NSLog(@"%@", date); > >It can on my machine (PST). If it can't on your machine, that sounds like a >bug. > >Also, do try -[dateFormatter getObjectValue:forString:errorDescription:]; It >is definitely throwing an error (not very helpful, "The operation couldn't be >completed") for your string on my machine. > >m. -- matt neuburg, phd = m...@tidbits.com, <http://www.apeth.net/matt/> A fool + a tool + an autorelease pool = cool! Programming iOS 4! http://www.apeth.net/matt/default.html#iosbook_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com