Re: NSDateFormatter problem
Re: NSDateFormatter problem
- Subject: Re: NSDateFormatter problem
- From: Lorenzo Thurman <email@hidden>
- Date: Fri, 20 Apr 2012 07:08:12 -0500
On Apr 19, 2012, at 10:18 PM, Keary Suska wrote:
>
> On Apr 19, 2012, at 5:38 PM, Lorenzo Thurman wrote:
>
>> This code, copied verbatim from here, http://bit.ly/HWTGB:
>>
>> NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
>> [dateFormatter setDateStyle:NSDateFormatterMediumStyle];
>> [dateFormatter setTimeStyle:NSDateFormatterNoStyle];
>>
>> NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:162000];
>>
>> NSString *formattedDateString = [dateFormatter stringFromDate:date];
>> NSLog(@"formattedDateString: %@", formattedDateString);
>>
>> produces this output:
>> formattedDateString: 01/02/01
>>
>> when it should produce this:
>> // Output for locale en_US: "formattedDateString: Jan 2, 2001"
>>
>> I have been testing some localizations, but I've only ever changed the language in the Language and Text System Preferences, none of the formatting options were changed, so I'm at a loss as to why this is happening. My original code is broken as well, producing the same mm/dd/yy output and it once worked perfectly. So I went back to basics and just copied the example code from Apple as a sanity check. Can someone provide some insight?
>
> Perhaps this excerpt from the API doc is key: "Do not use these constants if you want an exact format." Why, might be academic, but if you require a specific style, you may want to specify the style specifically.
>
> HTH,
>
> Keary Suska
> Esoteritech, Inc.
> "Demystifying technology for your home or business"
>
I have tried using strings to specify the styles, but no luck. Is there a way to reset the Language and Text Preferences? Is there an associated Preferences I can throw away?
Thanks for the reply.
The oldest known joke in the world.Approximate age: 5,000 years. Originating in China during the Bling-Bling Dynasty, which was marked by having enormously idiotic jokes written in gold inlay on elaborate ceramic urns, this joke is sometimes thought to be the very first joke ever written that included a question mark.
Two silk worms were in an obstacle-course race. What was the result?
... A tie.
Lorenzo Thurman
email@hidden
_______________________________________________
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