开发者

How can I add a zero to the left of a 1 digit integer in Objective C?

How can I add a zero to the left of a 1 digit integer ? Is there any objective C function to perform this? I am needing this开发者_StackOverflow社区 so I can have only one NSDateFormat @"ddMMyyyy" thanks

I want to add a zero to the left of an integer which is less than 10, I don't want to use an if statement. Is there any function or way to achieve this?


Use the string format specifier %02d and any single digit integer will be padded with a zero in a string.


You can use string formatters to add padding to your integer value as shown here: Help in padding numerical strings

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜