Re: Parsing a string into a NSDate
Re: Parsing a string into a NSDate
- Subject: Re: Parsing a string into a NSDate
- From: Bert Torfs <email@hidden>
- Date: Thu, 16 Mar 2006 18:18:51 +0100
Thanks,
This solves the problem. However, my Carbon sollution did complete
just a day with the current month and year. The cocoa implementation
wants the user to enter a complete day.
I'll use this sollution as a second try if the carbon one returns an
error.
Bert
On 15 Mar 2006, at 20:21, Nick Zitzmann wrote:
On Mar 15, 2006, at 12:01 PM, Bert Torfs wrote:
NSString* shortDateFormat;
shortDateFormat = [[NSUserDefaults standardUserDefaults]
objectForKey:NSShortDateFormatString]; // "%e/%m/%y"
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init]
autorelease];
[dateFormatter setDateFormat:shortDateFormat];
NSDate* ObjCDate = [dateFormatter dateFromString:inStringDate]; //
inStringDate = "15/03/06" result = 01/03/06 (????????)
The problem with this code is that todays date ("15/03/06") is
translated into 01/03/06 - the day part being wrong. What did I do
wrong?
You first need to set the date formatter behavior to 10.4 behavior,
then set the date style to the short style, and then set the time
style to no style. Then -dateFromString: ought to work as expected.
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden