I am using Date Formatter, getting the NSDateComponents. And then extracting the individual time components such as hour, minute..etc..
How can I extract these components as NSIntegers without losing the ‘0’ digits at the front of the number.
E.g is today was january 1 2010 5:05, it would print 1-1-2010-5:5
I want 01-01-2010-05:05
Any help would be appreciated
There is no way you can keep
0in theNSInteger. As such you can pick one of the approaches here –Avoid date components and reprint date in a different format using
NSDateFormatterFrom Date components
Using NSNumberFormatter (extending the previous block)