• 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 -dateFromString Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDateFormatter -dateFromString Question


  • Subject: Re: NSDateFormatter -dateFromString Question
  • From: Chris Kane <email@hidden>
  • Date: Tue, 15 Jul 2008 14:46:18 -0700

Once you did the -setFormatterBehavior:NSDateFormatterBehavior10_0, setDateFormat: became a no-op. setDateFormat: is a 10.4-behavior formatter method.

Per the doc:
http://developer.apple.com/documentation/Cocoa/Conceptual/DataFormatting/Articles/dfDateFormatting10_4.html#//apple_ref/doc/uid/TP40002369-SW1

The new methods in v10.4 do not do anything when invoked on a v10.0- style formatter, and return a generic return value when required to return something—you should therefore not invoke the new methods on a v10.0-style formatter. On a v10.4-style formatter, the old methods map approximately to one or more new methods or attributes, but you should use the new methods directly when possible.


setDateStyle: and setTimeStyle: are also 10.4-only. The 10.0 - 10.3 formatter basically had about 3 or 4 methods, only.



Chris Kane Cocoa Frameworks, Apple


On Jul 15, 2008, at 12:52, Steve Cronin wrote:

Folks;

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init] ;
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_0];
[dateFormatter setDateFormat:@"%m/%d/%Y %H:%M:%S %z"];
...
NSDate *myDate = [dateFormatter dateFromString:@"06/27/2008 02:51:52 -0500"];


myDate = 06/27/20.

What am I missing here? I expect the full date and time value to be reflected back in myDate...
I use 10_0 because I'm just more familiar..


I've tried adding:
[dateFormatter setDateStyle:NSDateFormatterLongStyle];
[dateFormatter setTimeStyle:NSDateFormatterFullStyle];

but that doesn't change anything...

Thanks for any help,
Steve

10.5.4 XC3.1
_______________________________________________

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

_______________________________________________

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: 
 >NSDateFormatter -dateFromString Question (From: Steve Cronin <email@hidden>)

  • Prev by Date: Re: [[NSDate alloc] initWithString] crashes with valid string
  • Next by Date: Inter-thread communications (live/deadlock?)
  • Previous by thread: NSDateFormatter -dateFromString Question
  • Next by thread: Mystery Thread - how to debug
  • Index(es):
    • Date
    • Thread