[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Formatting NSGregorianDate to a string.
On Wednesday, January 06, 1999 11:12 AM, Alex Horovitz
[SMTP:ahorovit@apple.com] wrote:
> > From: Endre Meckelborg Rognerud <e.m.rognerud@usit.uio.no>
> > To format a CalendarDate to a string, I used the method toString() with
fx a
> > parameter ("%d.%m.%Y"). This don't work with GregorianDate. What is the
> > easiest way to do the same with a GregorianDate?
>
>
> You can use a formatter like this:
>
> Assume the existance of some NSDate and do this:
>
> NSGregorianDateFormatter formatter = new
NSGregorianDateFormatter();
>
> try {
> myDate = (NSDate)formatter.objectValueForString(string);
> } catch (NSFormatter.ParsingException e) {
> myDate = null;
> }
>
>
> -Alex
>
>
Alex -
I notice that the original question asked was in regards to
NSGregorianDate, however, your response, and sample code, uses an NSDate.
Will the above solution also work if myDate is an NSGregorianDate?
thanks
mx.
Michael G Xenakis PLATINUM technology, inc
michael.xenakis@platinum.com 800.365.7528 x43007
"Anyone who isn't confused here doesn't really understand what's going on."
-?.?