Re: NSDateFormatter strangeness
Re: NSDateFormatter strangeness
- Subject: Re: NSDateFormatter strangeness
- From: Greg Hoover <email@hidden>
- Date: Tue, 18 Nov 2008 09:57:47 -0800
Wow! That totally fixed it. Thank you. Wow do I feel dumb!
Greg
On Nov 18, 2008, at 9:28 AM, Simon Wolf wrote:
On 18 Nov 2008, at 17:06, Greg Hoover wrote:
Ok, I buy that, but then what's the problem here:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat: @"dd/MM/YYYY"];
NSString *str = @"3/10/2008";
NSLog(@"%@\r%@\r%@", str, [formatter dateFromString: str],
[formatter stringFromDate: [formatter dateFromString: str]]);
[formatter release];
This code uses the formatter both directions but prints out the
following:
3/10/2008
2007-12-23 00:00:00 -0800
23/12/2007
So it's clear that there is a problem converting from the string to
date. Is there an issue with creating static NSDateFormatters?
Its curious because some of the date formatters in my app work as
expected, others do not.
Set your date format string to "dd/MM/yyyy"
[formatter setDateFormat: @"dd/MM/yyyy"];
Simon Wolf
Cocoa Blog: http://www.ottersoftware.com/developer//developer/
Twitter: http://www.twitter.com/sgaw
_______________________________________________
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