On Nov 9, 3:04 pm, "m" <mod...@gmail.com> wrote:
> Hi All
>
> Can you please tell me a way in which I can display a number with
> leading 0's. The total length of the number will be 5 digits.
>
> Ex: 5 as 00005, 25 as 00025, 125 as 00125 etc.
> I have a sequence which goes from 1 to a max of 99999.
>
> I know I can do it like this ..
> If (length(number)==1) { "0000"+number}
> else if (length(number)==2) { "000"+number}
>
> I am looking for any better solution. I use jdk1.5.0
>
> Thanks
I'd suggest taking a look at String.format
http://java.sun.com/j2se/1.5.0/docs/...va.lang.Object...)