Re: NSDateFormatter
Re: NSDateFormatter
- Subject: Re: NSDateFormatter
- From: Itrat Khan <email@hidden>
- Date: Wed, 21 Aug 2002 12:50:17 -0400
On Wednesday, August 21, 2002, at 12:20 PM, Ali Lalani (list) wrote:
I'm having a problem with NSDateFormatter. I'm wondering if it is
possible to get it to parse dates entered(on textfields with
dateformatters) with, say, Day/Month/Year configurations instead of
Month/Day/Year. This is not to be confused with dateFormat which
contains the format it turns dates entered into.
Both the parsing and display of dates is dictated by your format, so I'm
not sure how the parsing is not to be confused with dateFormat.
for instance if i type in:
09/06/02
it reads it as the 9th month, 6th day of 2002. I would like it to
interpret that string as the 9th day, 6th month, but i can't seem to
figure out how to instruct it to do so(my International preferences are
set to Day/Month/Year but it doesn't seem to take that into
consideration)...if anyone understands my babble and can help me out,
let me know, and thanks in advance :)
If you want to use the format defined in System Preferences, add
something like this in your controller's windowDidLoad:
format = [[NSUserDefaults standardUserDefaults]
objectForKey:NSShortDateFormatString];
formatter = [[NSDateFormatter allocWithZone:[self zone]]
initWithDateFormat:format
allowNaturalLanguage:NO];
[self->myTextCell setFormatter:formatter];
Alternatively, if you have natural language dates enabled,
NSDateFormatter can interpret stuff like "d:9 m:6: y:02" as "9th day,
6th month," regardless of the current format string.
Regards,
Itrat.
............................................................
Modeless Software, Inc.
London, Ontario (Canada)
Tel: +1 519 473 2037
Web: www.liquidledger.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.