Question

I have a date string (well, NSData, but that's easy to convert to a string) that's in what I believe is the format the HTTP standard uses:

Mon Apr 17 19:34:46 UTC 2006

Is there any better (i.e. less error-prone) way to parse that than specifying the format string by hand in an NSDateFormatter?

(My application is an iPhone app, but I suspect standard Cocoa solutions will work too, since NSDate and NSDateFormatter are part of Foundation.)

Was it helpful?

Solution

No, I don't think there is a better way.

If you have some outside input, you must know the format of your input beforehand, and you can only prepare for problems, i.e. a fail over parser with an alternate NSDateFormatter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top