Re: Simple date format problem? iOS 5
Re: Simple date format problem? iOS 5
- Subject: Re: Simple date format problem? iOS 5
- From: Jens Alfke <email@hidden>
- Date: Thu, 09 Aug 2012 18:35:33 -0700
On Aug 9, 2012, at 6:26 PM, Dave DeLong <email@hidden> wrote:
> I'm going to venture out on a limb and say you shouldn't be using NSDateFormatter for this. NSDateFormatter is really only useful when you're converting a date to-and-from a human-readable form. The way you're using it, it's not human-readable, and will cause you problems in very subtle ways.
I think that's going too far — you can use NSDateFormatter for this, as long as you reset the calendar and locale:
formatter.calendar = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
formatter.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease];
(I'm not sure whether [NSLocale systemLocale] would work as well; I'm copying this from some working code of mine that generates ISO-8601 date strings.)
—Jens
_______________________________________________
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