[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Formatting NSGregorianDate to a string.
> 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