Lorenzo:

By deleting "setDateStyle", the following provided the result I believe you 
hoped for:

NSDate *now = [[NSDate alloc] init];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];        
[dateFormatter setDateFormat:@"EEE_MMM_dd_yyyy"];
NSString *filenameDate = [dateFormatter stringFromDate:now];
NSLog(@"filenameDate: %@",filenameDate);
[dateFormatter release];
[now release];

My console output: 

2011-02-02 17:38:45.123 App[410:307] filenameDate: Wed_Feb_02_2011

Regards,

Roger Dalal
Assembled Apps




On Feb 2, 2011, at 4:30 PM, lorenzo7...@gmail.com wrote:

> On Feb 2, 2011 3:18pm, Ken Thomases <k...@codeweavers.com> wrote:
>> On Feb 2, 2011, at 3:14 PM, lorenzo7...@gmail.com wrote:
> 
> 
> 
>> > Here is the code I'm using to format a date string:
> 
>> >
> 
>> >
> 
>> > NSDate *date = [NSDate date];
> 
>> >
> 
>> > NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
> 
>> > [dateFormatter setDateStyle:NSDateFormatterBehavior10_4];
> 
> 
> 
>> The above should use -setFormatterBehavior:, not -setDateStyle:.
> 
> 
> 
>> > [dateFormatter setDateStyle:NSDateFormatterShortStyle];
> 
>> > // check placed here
> 
>> > [dateFormatter setDateFormat:@"EEE_MMM_dd_yyyy"];
> 
>> >
> 
>> > NSString * filenameDate = [dateFormatter stringFromDate:date];
> 
>> >
> 
>> > What I'm expecting is something like this:
> 
>> > Tue_Feb_02_2011
> 
>> >
> 
>> > What I'm getting is this:
> 
>> > 02/02/2011
> 
>> >
> 
>> > I even inserted this line just after the setDateFormat to see just what 
>> > the formatter would return as its format
> 
>> > NSString * df = [dateFormatter dateFormat];
> 
>> >
> 
>> > I get this back
> 
>> > 02/02/2001
> 
>> >
> 
>> > What gives? I've used NSDateFormatter before with no problems. I assume 
>> > I've missed something silly, but I just don't see it.
> 
> 
> 
>> Regards,
> 
>> Ken
> 
> 
> 
> 
> Sorry, that was a typo:
> This
> 
> NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
> [dateFormatter setDateStyle:NSDateFormatterBehavior10_4];
> [dateFormatter setDateFormat:@"EEE_MMM_dd_yyyy"];
> 
> NSString * filenameDate = [dateFormatter stringFromDate:date];
> 
> still produces
> 02/02/2011
> _______________________________________________
> 
> 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/roger.dalal%40gmail.com
> 
> This email sent to roger.da...@gmail.com

_______________________________________________

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

Reply via email to