开发者

What formatter pattern should I use to get '00123', '00001' strings from numbers '123' and '1' correspondingly?

I need to format numbers in a way that they should be preceded with zeros to contain开发者_运维百科 5 digits.

I don't get how to create patterns for java formatter.

I tried %4d but it doesn't adds zeros.


%05d should do it I believe


int a=123;   
System.out.println(String.format("%05d",a));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜