• 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: Simple date format problem? iOS 5
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Simple date format problem? iOS 5
      • From: Alex Kac <email@hidden>
References: 
 >Simple date format problem? iOS 5 (From: Alex Kac <email@hidden>)
 >Re: Simple date format problem? iOS 5 (From: Dave DeLong <email@hidden>)

  • Prev by Date: Re: Simple date format problem? iOS 5
  • Next by Date: Re: Simple date format problem? iOS 5
  • Previous by thread: Re: Simple date format problem? iOS 5
  • Next by thread: Re: Simple date format problem? iOS 5
  • Index(es):
    • Date
    • Thread