• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSDateFormatter not working on iOS 5.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDateFormatter not working on iOS 5.


  • Subject: Re: NSDateFormatter not working on iOS 5.
  • From: Kin Mak <email@hidden>
  • Date: Wed, 16 Nov 2011 16:29:41 +0800

Matt,

The result differs not only on simulator, but also on iphones running 4.3 and 5.0.
I have also found out that ONLY some of the known time zones work fine on 5.0. e.g. PDT, PST, GMT ...etc. However, all time zones work fine on iOS 4.3.
In fact, I have already reported this as a bug to apple.

Thanks and Regards
Kin

On Nov 15, 2011, at 11:11 PM, Matt Neuburg wrote:

> 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 <email@hidden> 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 = email@hidden, <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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >Re: NSDateFormatter not working on iOS 5. (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: What's the best practice to write some common tasks?
  • Next by Date: Re: About iVars declaration and property
  • Previous by thread: Re: NSDateFormatter not working on iOS 5.
  • Next by thread: Re: NSDateFormatter not working on iOS 5.
  • Index(es):
    • Date
    • Thread