格式化字符串有什么捷径吗?
我正在使用目标c,并且我得到了一些像这样的变量:
1100
920
845
1439
但我想将其更改为:
11:00
09:20
08:45
14:39
问题是当我只得到三个数字时如何填充零?我知道逻辑可以很简单,我检测字符串长度,但是有什么方法可以更有效地做到这一点吗?谢谢。
I am using objective c, and I got some variables like this:
1100
920
845
1439
But I want to change it to :
11:00
09:20
08:45
14:39
The problem is how can I fill the zero when I got three number only? I know the logic can be simple to do it I detect the string length, but is there any way to do it more effectually? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)