NSDate, NSDateFormatter, and NSDatePicker
NSDate, NSDateFormatter, and NSDatePicker
- Subject: NSDate, NSDateFormatter, and NSDatePicker
- From: Pete Bates <email@hidden>
- Date: Fri, 13 Jan 2006 07:21:02 -0700
I'm trying to set the display of a date picker to a date retrieved
from a database in the form "mm-dd-yyyy". Eliminating the data
retrieval code, the code looks like so:
NSString * theDateString;
theDateString=@"05-01-1994";
NSDate * aDate;
aDate=[[NSDate alloc]init];
NSDateFormatter * aDateFormatter;
aDateFormatter=[[NSDateFormatter alloc] init];
[aDateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[aDateFormatter setDateFormat:@"mm-dd-yyyy"];
aDate=[aDateFormatter dateFromString:theDateString];
[dobPicker setDateValue:aDate];
NSLog(@"The date format is: %@",[aDateFormatter dateFormat]);
NSLog(@"The date string is: %@",theDateString);
NSLog(@"The created date is: %@",aDate);
But here is the Log Output:
The date format is: mm-dd-yyyy
The date string is: 05-01-1994
The created date is: 1994-01-01 00:05:00 -0700
and of course the date picker displays 1/1/1994
Obviously either I'm doing something wrong, or the software is doing
something wrong. As hard as it is for me to think so, it could be
me... :0
Would someone be so kind as to steer me in the right direction?
Thanks.
Pete
_______________________________________________
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