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));
精彩评论