Wednesday, 22 April 2009

NSDateFormatter in OSX 10.4.11

Today I found some strange behaviour in the NSDateFormatter :
If I execute the following code :

NSDateFormatter *timeFormatter = [[[NSDateFormatter alloc] init] autorelease];
[timeFormatter setDateStyle:NSDateFormatterNoStyle];
[timeFormatter setTimeStyle:NSDateFormatterMediumStyle];
NSDate *stringTime = [NSDate date];
NSString *formattedDateStringTime = [timeFormatter stringFromDate:stringTime];
[theTime setStringValue: formattedDateStringTime] ;

Then , instead of displaying the time, it shows me the date.

If I add the following line on top :

[NSDateFormatter setDefaultFormatterBehavior: NSDateFormatterBehavior10_4] ;

It gives me correctly the time.

is this something specific for the 10.4.11 ? Is this behavior also observed in the 10.5.X ?

No comments:

Post a Comment