In article <. com>, m
took the hamburger meat, threw it on the grill, and I said "Oh Wow"...
> 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
>
>
public String pimpMyNumber(int aNumber) {
DecimalFormat df = new DecimalFormat("000,000");
StringBuffer sb = df.format(aNumber);
return sb.toString();
}
--
trippy
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM
NP: "All I Really Want" -- Alanis Morissette
"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum, a pocketknife,
and a smile."
-- Robert Redford "Spy Game"
|